結果

問題 No.85 TVザッピング(1)
ユーザー lam6er
提出日時 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
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

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")
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0