QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#847003 | #5736. Black and White | Yarema# | AC ✓ | 0ms | 3864kb | C++20 | 1.1kb | 2025-01-07 16:49:30 | 2025-01-07 16:49:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int m = n;
vector<string> v(n);
FOR (i, 0, n) cin >> v[i];
bool ok = true;
FOR (i, 0, n)
{
map<char, int> cnt;
FOR (j, 0, m)
{
cnt[v[i][j]]++;
if (j + 2 < m && v[i][j] == v[i][j + 1] && v[i][j] == v[i][j + 2])
ok = false;
}
if (cnt['W'] != n / 2)
ok = false;
}
FOR (j, 0, m)
{
map<char, int> cnt;
FOR (i, 0, n)
{
cnt[v[i][j]]++;
if (i + 2 < n && v[i][j] == v[i + 1][j] && v[i + 2][j] == v[i][j])
ok = false;
}
if (cnt['W'] != n / 2)
ok = false;
}
cout << ok << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
4 WBBW WBWB BWWB BWBW
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
4 BWWB BWBB WBBW WBWW
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
6 BWBWWB WBWBWB WBBWBW BBWBWW BWWBBW WWBWBB
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
6 WWBBWB BBWWBW WBWBWB BWBWBW BWBBWW WBWWBB
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
10 BBWWBBWWBW BWBBWBWBWW WBBWBWBWWB WBWBWWBWBB BWBWWBWBBW WBWBBWBBWW BWBWWBWWBB WBWBBWBWWB WWBWBBWBBW BWWBWWBBWB
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
12 BWWBBWBWWBBW BWWBWBWWBWBB WBBWBWBBWBWW WBBWBBWWBWBW BWWBWWBBWBWB WBBWBWWBBWBW BWWBWBBWWBWB WBWBWBWBBWWB BWBWBWBWWBBW WWBBWBWBWBWB BBWWBWBWBWWB WBBWWBWBBWBW
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
2 WB BW
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 WBWB WBBW BWWB BWBW
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
6 WWBBWB BBWBWW BBWWBW WWBWBB WWBBWB BBWWBW
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
8 WBBWBWBW BWWBWBBW BBWWBWWB WWBBWBWB WBWBWBBW BWBWBWWB BWBWWBBW WBWBBWWB
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
24 BBWWBWWBBWWBBWBBWWBWWBBW WBWBWBBWWBBWWBWBWBWBBWWB BWBWBWWBBWBBWBWWBWBWBBWW WBWBWBWBWBWWBWBWBBWBWWBB WBWWBWBWWBWWBBWBWBBWBBWB BWBBWBBWBWBBWWBWBWBWWBWW WWBWWBWBBWWBBWBBWBWBWWBB BBWBBWBWWBWWBBWWBWBWBWBW WBBWBWWBWWBBWBBWWBWWBBWB BWBWWBBWBBWBBWWBWBWBWBWW WBWBBWBWWBBWWBBWBWBBWWBW BWWBWBWBBWBWBBWBWWBWBW...
output:
1
result:
ok single line: '1'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
24 WBWWBWBBWBWBWBBWWBBWWBBW BWWBBWWBWWBWBBWBBWWBWBWB WWBBWBBWBBWBBWBWWBWWBWBW WBBWWBBWBWBBWBWBWWBBWWBW BBWWBWWBWWBWBWBWBBWWBBWB BWBBWWBWWBWBBWWBWBBWBWBW WBWBWBWBBWBWWBWWBWBBWBWB WBBWBWBWBWWBWWBBWBWWBWBB BWBWBBWBWBWWBWBWBWBBWWBW BWWBWBBWWBBWWBWBBWBWBBWW WBBWBWBWBWBBWWBWWBWBBWWB BBWWBWWBWBWWBBWBWBWBWB...
output:
1
result:
ok single line: '1'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
24 WBWWBWBWBWBBWWBBWBBWBBWW BWBBWBBWWBBWWBWWBWWBWWBB WWBBWBWBWBWWBWBWWBBWBBWB BBWWBWBWBWWBBWWBBWWBWBBW BWWBWWBBWBBWWBBWWBWBWWBB WBBWWBWBBWWBWWBBWBBWBBWW WBBWBWBWWBWWBBWBBWWBWWBB BWWBWBWBBWBWBWBWWBBWBWWB WBBWBWBWBBWBWBWBBWWBWBWW BWBWWBWBWBBWBBWWBWBBWWBW WBWBBWBWBWWBBWBBWBWWBWWB BWWBWBWWBBWBWWBWBWBBWB...
output:
1
result:
ok single line: '1'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
24 WBBWWBBWWBWWBWBBWWBWBWBB BWWBWBWBBWBBWWBBWWBBWWBW WBBWBWWBWBBWBBWWBBWWBBWW BWWBWBBWWBWBWWBBWBBWWBWB WBBWWBBWBWBWBWBWBWBBWWBW WBWBBWWBWWBBWBWBWBWBBWWB BWBBWWBBWBWBWBWWBBWWBBWW BWBWBBWWBWBWBWBWBWBBWWBW WBWWBWBBWBWBWBWBWBBWWBWB BBWBWWBWBWBWWBBWWBWWBWBB WWBBWBWBBWWBBWWBBWWBWBBW WBBWBWWBWBWWBBWBBWBWBW...
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWBWBBWBWWBBWBWW WBWBWBBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWWBBBWBWWBBWBWW WBWBWBBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWBWBBWBWWBBWBWW WBWBBWBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWBWBBWBWWBBWBWW WBWBWBBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
0
result:
ok single line: '0'