結果
問題 |
No.3041 非対称じゃんけん
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:23:48 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 327 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 67,732 KB |
最終ジャッジ日時 | 2025-06-12 13:28:50 |
合計ジャッジ時間 | 3,377 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | RE * 30 |
ソースコード
n = int(input()) if n == 0: print("No") exit() # dp[i][j] = whether the current player can win with i petals left and current parity j (0: even, 1: odd) dp = [[False] * 2 for _ in range(n + 1)] # Base case: 0 petals left dp[0][0] = False # even total, current player loses dp[0][1] = True # odd total, current player wins for i in range(1, n + 1): for p in [0, 1]: can_win = False for m in [1, 2, 3]: if m > i: continue remaining = i - m new_p = (p + m) % 2 if remaining == 0: # Game ends after this move if new_p == 1: can_win = True break else: # Check if the opponent cannot win in the next state if not dp[remaining][new_p]: can_win = True break dp[i][p] = can_win print("Yes" if dp[n][0] else "No")