QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623160#5736. Black and WhitepurelyKaiRE 0ms0kbPython31.1kb2024-10-09 10:26:422024-10-09 10:26:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 10:26:44]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-09 10:26:42]
  • 提交

answer

import sys
sys.stdin = open('blackOrWhiteInput.txt', 'r')

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
        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
        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: 0
Dangerous Syscalls

input:

4
WBBW
WBWB
BWWB
BWBW

output:


result: