QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623182 | #5736. Black and White | purelyKai | AC ✓ | 16ms | 10740kb | Python3 | 1.1kb | 2024-10-09 10:30:23 | 2024-10-09 10:30:30 |
Judging History
answer
def blackOrWhite(n, board):
t = 0
b = 0
w = 0
for i in range(n):
for j in range(n):
if board[i][j] == 'B':
t = t + 1
w = 0
b = b + 1
else:
t = t - 1
b = 0
w = w + 1
if b == 3 or b == -3 or w == 3 or w == -3:
print(0)
return
w = 0
b = 0
if t != 0:
print(0)
return
for i in range(n):
for j in range(n):
if board[j][i] == 'B':
t = t + 1
w = 0
b = b + 1
else:
t = t - 1
b = 0
w = w + 1
if b == 3 or b == -3 or w == 3 or w == -3:
print(0)
return
w = 0
b = 0
if t != 0:
print(0)
return
print(1)
return
n = int(input())
board = []
for i in range(n):
s = input()
board.append(list(s))
blackOrWhite(n, board)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 10640kb
input:
4 WBBW WBWB BWWB BWBW
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 8ms
memory: 10700kb
input:
4 BWWB BWBB WBBW WBWW
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 16ms
memory: 10636kb
input:
6 BWBWWB WBWBWB WBBWBW BBWBWW BWWBBW WWBWBB
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 9ms
memory: 10572kb
input:
6 WWBBWB BBWWBW WBWBWB BWBWBW BWBBWW WBWWBB
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 11ms
memory: 10636kb
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: 10ms
memory: 10704kb
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: 16ms
memory: 10648kb
input:
2 WB BW
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 15ms
memory: 10648kb
input:
4 WBWB WBBW BWWB BWBW
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 10ms
memory: 10644kb
input:
6 WWBBWB BBWBWW BBWWBW WWBWBB WWBBWB BBWWBW
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 6ms
memory: 10632kb
input:
8 WBBWBWBW BWWBWBBW BBWWBWWB WWBBWBWB WBWBWBBW BWBWBWWB BWBWWBBW WBWBBWWB
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 16ms
memory: 10712kb
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: 13ms
memory: 10584kb
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: 16ms
memory: 10528kb
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: 12ms
memory: 10584kb
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: 16ms
memory: 10608kb
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: 12ms
memory: 10608kb
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: 10ms
memory: 10740kb
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: 10ms
memory: 10584kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWBWBBWBWWBBWBWW WBWBWBBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
0
result:
ok single line: '0'