結果

問題 No.1935 Water Simulation
コンテスト
ユーザー ntuda
提出日時 2025-10-15 23:05:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 82,892 KB
実行使用メモリ 55,848 KB
最終ジャッジ日時 2025-10-15 23:05:25
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
VN = list(map(int,input().split()))
V = VN[:4]
N = VN[4]
dic = defaultdict(int)
S = [V[0],0,0,0]
X = [tuple(S)]
dic[X[0]] = 0
turn = 0
tturn = 0
while turn < N:
    turn2 = (turn + 1) % 4
    s0 = S[turn]
    s1 = S[turn2]
    if s0 + s1 <= V[turn2]:
        S[turn2] = s0 + s1
        S[turn] = 0
    else:
        S[turn + 1] = V[turn2]
        S[turn] = s0 + s1 - V[turn2]
    tturn += 1
    turn += 1
    turn %= 4
    TS = tuple(S)
    if TS not in dic:
        X.append(TS)
        dic[TS] = tturn
    else:
        st = dic[TS]
        loop = tturn - st
        N2 = (N - st) % loop
        print(*X[st+N2])
        exit()
print(*TS)

0