結果

問題 No.1935 Water Simulation
コンテスト
ユーザー ntuda
提出日時 2025-10-15 23:12:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 80 ms / 2,000 ms
+ 122µs
コード長 694 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2026-07-15 17:12:01
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 tturn < 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+[turn])
    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][:4])
        exit()
print(*TS[:4])

0