-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw15612.cpp
More file actions
49 lines (44 loc) · 828 Bytes
/
sw15612.cpp
File metadata and controls
49 lines (44 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
using namespace std;
vector<pair<int, int>>v;
bool row[8];
bool col[8];
bool chess(int idx) {
if (idx == v.size()) {
return true;
}
int x = v[idx].first, y = v[idx].second;
if (row[x] || col[y]) {
return false;
}
row[x] = true;
col[y] = true;
chess(idx + 1);
}
int main() {
int test = 0;
cin >> test;
for (int t = 1; t <= test; t++) {
v.clear();
memset(row, 0, sizeof(row));
memset(col, 0, sizeof(col));
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
char c;
cin >> c;
if (c == 'O') {
v.push_back({ i,j });
}
}
}
if (v.size() != 8) {
cout << "#" << t << " " << "no" << "\n";
continue;
}
string res = chess(0) ? "yes" : "no";
cout << "#" << t << " " << res << "\n";
}
}