結果

問題 No.1935 Water Simulation
ユーザー abab
提出日時 2022-05-13 22:13:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 55,620 KB
最終ジャッジ日時 2024-07-22 02:10:41
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import count

*V, n = map(int, input().split())

now = [0] * 4
now[0] = V[0]

idx = defaultdict(lambda : -1)
route = []

for i in count():
    idx[tuple(now)] = i
    route.append(now[:])

    l, r = i % 4, (i + 1) % 4
    move = min(now[l], V[r] - now[r])
    now[l] -= move
    now[r] += move

    if tuple(now) in idx:
        break

loop = idx[tuple(now)]

if n < loop:
    print(*route[n])
else:
    route = route[loop:]
    n -= loop
    print(*route[n % len(route)])
0