QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623149 | #5736. Black and White | larsotaz | AC ✓ | 15ms | 10752kb | Python3 | 1.5kb | 2024-10-09 10:23:30 | 2024-10-09 10:23:32 |
Judging History
answer
def inp(): # For taking integer inputs.
return(int(input()))
def inlst(): # For taking List inputs.
return(list(map(int,input().split())))
# For taking string inputs. Actually it returns a List of Characters, instead of a string,
def instr():
s = input()
return(list(s[:len(s)]))
n = inp()
board = ["" for _ in range(n)]
for i in range(n):
board[i] = instr()
def checkRow(row):
b = 0
w = 0
wThre = 0
bThre = 0
for c in row:
if c == "W":
w += 1
wThre += 1
bThre = 0
else:
b += 1
wThre = 0
bThre += 1
if bThre == 3 or wThre == 3:
# print("YAY")
return False
return w==b
def checkCol(i):
b = 0
w = 0
wThre = 0
bThre = 0
for j in range(len(board)):
if board[j][i] == "W":
w += 1
wThre += 1
bThre = 0
else:
b += 1
wThre = 0
bThre += 1
if bThre == 3 or wThre == 3:
# print("NAY")
return False
return w==b
valid = True
for i in range(len(board[0])):
valid = checkCol(i)
# print(valid)
if not valid:
print(0)
break
if valid:
for row in board:
# print(row)
valid = checkRow(row)
# print(valid)
if not valid:
print(0)
break
if valid:
print(1)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 10612kb
input:
4 WBBW WBWB BWWB BWBW
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 7ms
memory: 10716kb
input:
4 BWWB BWBB WBBW WBWW
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 12ms
memory: 10636kb
input:
6 BWBWWB WBWBWB WBBWBW BBWBWW BWWBBW WWBWBB
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 10ms
memory: 10632kb
input:
6 WWBBWB BBWWBW WBWBWB BWBWBW BWBBWW WBWWBB
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 8ms
memory: 10660kb
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: 15ms
memory: 10712kb
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: 7ms
memory: 10644kb
input:
2 WB BW
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 4ms
memory: 10632kb
input:
4 WBWB WBBW BWWB BWBW
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 11ms
memory: 10656kb
input:
6 WWBBWB BBWBWW BBWWBW WWBWBB WWBBWB BBWWBW
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 10644kb
input:
8 WBBWBWBW BWWBWBBW BBWWBWWB WWBBWBWB WBWBWBBW BWBWBWWB BWBWWBBW WBWBBWWB
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 9ms
memory: 10592kb
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: 7ms
memory: 10752kb
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: 7ms
memory: 10752kb
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: 11ms
memory: 10712kb
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: 7ms
memory: 10728kb
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: 6ms
memory: 10588kb
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: 15ms
memory: 10716kb
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: 15ms
memory: 10600kb
input:
24 WBWBWBBWBBWWBBWBWBWWBWWB BWBWBWWBBWBBWWBWBWBBWWBW WBBWWBBWWBWBBWWBWBWWBBWB BBWBBWWBWWBWWBBWBWBBWBWW WWBWWBBWBBWBWBWBWBWWBWBB BBWBWWBWWBBWBWWBBWWBWBBW WBBWBBWBWWBBWBBWBWBWWBWW BWBBWBWWBWWBBWWBWBWWBWBB WBWWBWBWWBBWWBBWBBWBWBBW BWBWBWWBBWBWBBWBWWBBWBWW WBWBWBBWBWWBBWBWWBBWBWWB BWWBBWWBWBBWWBBWBBWWBW...
output:
0
result:
ok single line: '0'