728x90
programmers.co.kr/learn/courses/30/lessons/17681
#include <string>
#include <vector>
using namespace std;
vector<string> solution(int n, vector<int> arr1, vector<int> arr2) {
string str = "";
vector<vector<int>> v1(n, vector<int>(n));
vector<vector<int>> v2(n, vector<int>(n));
for(int i = 0; i < n; i++) {
str += " ";
}
for(int i = 0; i < n; i++) {
int num = arr1[i];
vector<int> temp;
while(num > 0) {
temp.push_back(num % 2);
num /= 2;
}
int index = n - 1;
for(int j = 0; j < temp.size(); j++) {
v1[i][index--] = temp[j];
}
}
for(int i = 0; i < n; i++) {
int num = arr2[i];
vector<int> temp;
while(num > 0) {
temp.push_back(num % 2);
num /= 2;
}
int index = n - 1;
for(int j = 0; j < temp.size(); j++) {
v2[i][index--] = temp[j];
}
}
vector<string> answer(n, str);
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if (v1[i][j] == 1 || v2[i][j] == 1) {
answer[i][j] = '#';
}
}
}
return answer;
}
728x90
'알고리즘 문제' 카테고리의 다른 글
[2018 KAKAO BLIND RECRUITMENT 1차] 다트 게임 (0) | 2021.04.19 |
---|---|
[2018 KAKAO BLIND RECRUITMENT 1차] 추석 트래픽 (0) | 2021.04.16 |
[2018 KAKAO BLIND RECRUITMENT 1차] 프렌즈4블록 (0) | 2021.04.16 |
[백준] 2805번 나무 자르기 (0) | 2021.02.16 |
[백준] 1011번 Fly me to the Alpha Centauri (0) | 2021.02.10 |