結果

問題 No.86 TVザッピング(2)
ユーザー gew1fw
提出日時 2025-06-12 14:53:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 62,240 KB
最終ジャッジ日時 2025-06-20 14:02:37
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx +=1
    M = int(input[idx])
    idx +=1

    grid = []
    for _ in range(N):
        grid.append(input[idx])
        idx +=1

    # Compute all accessible buttons
    accessible = []
    for i in range(N):
        for j in range(M):
            if grid[i][j] == '.':
                accessible.append( (i,j) )

    K = len(accessible)
    if K % 2 != 0:
        print("NO")
        return

    # Compute black and white counts
    black = 0
    white = 0
    for (i,j) in accessible:
        if (i + j) % 2 == 0:
            black +=1
        else:
            white +=1

    if black == white:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()
0