-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathc1.cpp
47 lines (44 loc) · 1.18 KB
/
c1.cpp
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
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int T, N;
string s[300];
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> T;
while(T--){
cin >> N;
for(int i = 0; i < N; i++){
cin >> s[i];
}
int xs = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
xs += (s[i][j] == 'X');
}
}
for(int offset = 0; offset < 3; offset++){
int cx = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
cx += (s[i][j] == 'X' && (i + j + offset) % 3 == 0);
}
}
if(cx <= xs/3){
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(s[i][j] == '.') cout << '.';
else if((i + j + offset) % 3 == 0){
cout << 'O';
}else{
cout << 'X';
}
}
cout << endl;
}
break;
}
}
}
}