結果

問題 No.923 オセロきりきざむたん
ユーザー gew1fw
提出日時 2025-06-12 21:43:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,066 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 100,032 KB
最終ジャッジ日時 2025-06-12 21:47:13
合計ジャッジ時間 7,424 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    H = int(data[0])
    W = int(data[1])
    grid = data[2:]
    
    # Check if the entire grid is already all 1s
    all_ones = True
    for row in grid:
        if '0' in row:
            all_ones = False
            break
    if all_ones:
        if H * W == 1:
            print("YES")
        else:
            print("NO")
        return
    
    # Calculate the required flips F_ij = 1 - A_ij
    required = []
    for row in grid:
        req = []
        for c in row:
            req.append(1 - int(c))
        required.append(req)
    
    # Check for possible configurations
    # We need to determine if the required flips can be achieved
    # through a series of splits and mandatory flips.
    # For this problem, the solution is to check if the sum of all required flips is even.
    total = 0
    for row in required:
        total += sum(row)
    
    if total % 2 == 0:
        print("YES")
    else:
        print("NO")

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