結果
| 問題 |
No.85 TVザッピング(1)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:49:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,180 bytes |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 82,088 KB |
| 実行使用メモリ | 53,684 KB |
| 最終ジャッジ日時 | 2025-03-20 18:52:08 |
| 合計ジャッジ時間 | 2,177 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
n, m, c = map(int, input().split())
# Handle single row or column case
if n == 1 or m == 1:
print("NO")
else:
# Calculate position (x, y) of C
x = (c - 1) // m + 1
y = c - (x - 1) * m
# Collect valid neighbors
neighbors = []
for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
nx = x + dx
ny = y + dy
if 1 <= nx <= n and 1 <= ny <= m:
neighbors.append((nx, ny))
# Calculate colors of neighbors
colors = []
for (nx, ny) in neighbors:
colors.append((nx + ny) % 2)
# Determine s_parity
total = n * m
s_parity = (total - 2) % 2
possible = False
if s_parity == 0:
# Need at least two neighbors with the same color
color_count = {}
for color in colors:
color_count[color] = color_count.get(color, 0) + 1
for cnt in color_count.values():
if cnt >= 2:
possible = True
break
else:
# Need at least two different colors
unique_colors = set(colors)
if len(unique_colors) >= 2:
possible = True
print("YES" if possible else "NO")
lam6er