結果

問題 No.1770 N言っちゃダメゲーム (6)
ユーザー Kude
提出日時 2021-12-02 07:05:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 92,288 KB
最終ジャッジ日時 2024-07-05 01:47:17
合計ジャッジ時間 4,560 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n, k = map(int, input().split())
wins = deque()
win_others = [[] for  _ in range(n)]
for i in range(n - 1, 0, -1):
    cnt = len(wins) + len(win_others[i])
    if cnt == 0:
        wins.appendleft(i)
    elif cnt == 1:
        j = wins[0] if wins else win_others[i][0]
        p = i - (j - i)
        if p >= 0:
            win_others[p].append(i)
    if wins and wins[-1] == i + k:
        wins.pop()
ans = sorted(win_others[0] + list(wins))
if ans:
    print(*ans, sep='\n')
else:
    print(0)
0