結果

問題 No.3041 非対称じゃんけん
ユーザー lam6er
提出日時 2025-04-16 01:11:54
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 845 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,116 KB
実行使用メモリ 66,500 KB
最終ジャッジ日時 2025-04-16 01:13:22
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

# Initialize DP table
# dp[i][s] represents if the current player can win with i petals left and state s
# s=0 (kirai), s=1 (suki)
dp = [[False] * 2 for _ in range(n + 1)]

# Base case: 0 petals left
dp[0][1] = True  # suki state means win
dp[0][0] = False  # kirai state means lose

for i in range(1, n + 1):
    for s in [0, 1]:
        can_win = False
        for x in range(1, 4):
            if i >= x:
                next_n = i - x
                next_s = 1 - s  # Toggle the state
                if next_n == 0:
                    if next_s == 1:
                        can_win = True
                        break
                else:
                    if not dp[next_n][next_s]:
                        can_win = True
                        break
        dp[i][s] = can_win

print("Yes" if dp[n][0] else "No")
0