結果
問題 | No.85 TVザッピング(1) |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:20:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,180 bytes |
コンパイル時間 | 230 ms |
コンパイル使用メモリ | 82,384 KB |
実行使用メモリ | 54,192 KB |
最終ジャッジ日時 | 2025-03-20 21:21:46 |
合計ジャッジ時間 | 2,403 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
n, m, c = map(int, input().split())# Handle single row or column caseif n == 1 or m == 1:print("NO")else:# Calculate position (x, y) of Cx = (c - 1) // m + 1y = c - (x - 1) * m# Collect valid neighborsneighbors = []for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:nx = x + dxny = y + dyif 1 <= nx <= n and 1 <= ny <= m:neighbors.append((nx, ny))# Calculate colors of neighborscolors = []for (nx, ny) in neighbors:colors.append((nx + ny) % 2)# Determine s_paritytotal = n * ms_parity = (total - 2) % 2possible = Falseif s_parity == 0:# Need at least two neighbors with the same colorcolor_count = {}for color in colors:color_count[color] = color_count.get(color, 0) + 1for cnt in color_count.values():if cnt >= 2:possible = Truebreakelse:# Need at least two different colorsunique_colors = set(colors)if len(unique_colors) >= 2:possible = Trueprint("YES" if possible else "NO")