結果

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

ソースコード

diff #

from collections import defaultdict


v1, v2, v3, v4, N = map(int, input().split())
V = [v1, v2, v3, v4]
start = (v1, 0, 0, 0)
dist = defaultdict(lambda: -1)

status = defaultdict(tuple)
now = start
d, pt = 0, 0
while dist[now] == -1:
    dist[now] = d
    status[d] = now
    next = list(now)
    delta = min((V[(pt + 1) % 4] - now[(pt + 1) % 4]), now[pt])
    next[pt] -= delta
    next[(pt + 1) % 4] += delta
    d, pt = d + 1, (pt + 1) % 4
    now = tuple(next)
    print(now)

cycle_length = d - dist[now]
# print(cycle_length)
if N < d:
    exit(print(*status[d-1]))

N -= d - cycle_length
N %= cycle_length
print(*status[(d - cycle_length + N) % d])

0