[문제 링크] : https://www.acmicpc.net/problem/2596
#include <iostream>
#include <string>
using namespace std;
int N;
string S;
string Arr[8] = {"000000","001111","010011","011100","100110","101001","110101","111010"};
int cmp(string s, int n){
int res = 0;
for(int j=0; j<6; j++){
if(Arr[n][j] != s[j]){
res++;
}
}
return res;
}
int main(){
cin >> N >> S;
string Ans;
for(int i=0; i<N; i++){
string tmp = S.substr(i*6, 6);
bool flag = 0;
for(int j=0; j<8; j++){
if(cmp(tmp, j) <= 1){
flag=1;
Ans += ('A' + j);
break;
}
}
if(flag == false){
cout << i+1;
return 0;
}
}
cout << Ans << "\n";
return 0;
}
'알고리즘' 카테고리의 다른 글
[알고리즘] 백준 9501 - 꿍의 우주여행 (C++) (0) | 2025.04.28 |
---|---|
[알고리즘] 백준 9713 - Sum of Odd Sequence (C++) (0) | 2025.04.27 |
[알고리즘] 백준 14623 - 감정이입 (C++) (0) | 2025.04.25 |
[알고리즘] 백준 10834 - 벨트 (C++) (0) | 2025.04.24 |
[알고리즘] 백준 25704 - 출석 이벤트 (C++) (0) | 2025.04.23 |