結果

問題 No.1935 Water Simulation
ユーザー rlangevin
提出日時 2023-06-07 12:25:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 756 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-12-29 17:43:08
合計ジャッジ時間 3,186 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

V = list(map(int, input().split()))
N = V.pop()

D = dict()
now = (V[0], 0, 0, 0)
cnt = 0
D[now] = cnt
L = [now]
while True:
    # print("test", cnt, now)
    i = cnt%4
    ni = (i + 1)%4
    nex = [0] * 4
    if now[i] + now[ni] >= V[ni]:
        nex[ni] = V[ni]
        nex[i] = now[i] + now[ni] - V[ni]
    else:
        nex[ni] = now[i] + now[ni]
        nex[i] = 0

    for j in range(4):
        if j not in [i, ni]:
            nex[j] = now[j]
    nex = tuple(nex)
    if nex in D:
        N -= D[nex]
        loop = cnt - D[nex] + 1
        L = L[D[nex]:]
        print(*L[N%loop])
        exit()
    else:
        cnt += 1
        D[nex] = cnt
        L.append(nex)
        if cnt == N:
            print(*nex)
            exit()
        now = nex
0