結果

問題 No.923 オセロきりきざむたん
ユーザー lam6er
提出日時 2025-03-26 16:00:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 87,008 KB
最終ジャッジ日時 2025-03-26 16:01:17
合計ジャッジ時間 8,924 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 WA * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
grid = []
for _ in range(H):
    line = input().strip()
    grid.append([int(c) for c in line])

# Calculate the desired flip counts (f_ij = 1 - A_ij)
total = 0
column_sums = [0] * W
for i in range(H):
    for j in range(W):
        f = 1 - grid[i][j]
        total += f
        column_sums[j] += f

total_mod = total % 2
possible = True

# Check total condition
if total_mod != 0:
    possible = False
else:
    # Check each column's condition
    for j in range(W):
        sum_col = column_sums[j] % 2
        expected = (H - 1) % 2
        if sum_col != expected:
            possible = False
            break

print("YES" if possible else "NO")
0