https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Psz16AYEDFAUq
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T; cin >> T;
for (int t = 1; t <= T; t++) {
bool flag = true;
bool row[9][10] = { false };
bool col[9][10] = { false };
bool squ[9][10] = { false };
for (int i = 0; i < 9; i++) {
for (int k = 0; k < 9; k++) {
int n; cin >> n;
if (flag) {
int index = (i / 3) * 3 + k / 3;
if (!row[i][n] && !col[k][n] && !squ[index][n]) {
row[i][n] = col[k][n] = squ[index][n] = true;
}
else {
flag = false;
}
}
}
}
cout << "#" << t << " " << flag << endl;
}
}
'전공공부 > 코딩테스트' 카테고리의 다른 글
(c++) SWEA "1215) 회문1" (0) | 2022.05.28 |
---|---|
(c++) SWEA "2806) N-Queen" (0) | 2022.05.28 |
(c++) SWEA "2805) 농작물 수확" (0) | 2022.05.28 |
(c++) SWEA "2007) 패턴 마디의 길이" (0) | 2022.05.28 |
(c++) SWEA "1928) Base64 Decoder" (0) | 2022.05.28 |