結果

問題 No.1935 Water Simulation
ユーザー rlangevinrlangevin
提出日時 2023-06-07 12:30:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 802 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 76,816 KB
最終ジャッジ日時 2023-08-28 15:13:04
合計ジャッジ時間 3,739 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,096 KB
testcase_01 AC 78 ms
76,816 KB
testcase_02 AC 70 ms
71,372 KB
testcase_03 AC 71 ms
71,212 KB
testcase_04 AC 70 ms
71,336 KB
testcase_05 AC 69 ms
71,544 KB
testcase_06 AC 70 ms
71,164 KB
testcase_07 AC 71 ms
71,372 KB
testcase_08 AC 71 ms
71,144 KB
testcase_09 AC 69 ms
71,324 KB
testcase_10 AC 69 ms
71,400 KB
testcase_11 AC 69 ms
71,320 KB
testcase_12 AC 70 ms
71,196 KB
testcase_13 AC 69 ms
71,536 KB
testcase_14 AC 70 ms
71,376 KB
testcase_15 AC 70 ms
71,300 KB
testcase_16 AC 70 ms
71,480 KB
testcase_17 AC 69 ms
70,988 KB
testcase_18 AC 68 ms
70,984 KB
testcase_19 AC 69 ms
71,388 KB
testcase_20 AC 69 ms
71,392 KB
testcase_21 AC 70 ms
71,200 KB
testcase_22 AC 69 ms
71,400 KB
testcase_23 AC 69 ms
71,356 KB
testcase_24 AC 69 ms
71,480 KB
testcase_25 AC 70 ms
70,988 KB
testcase_26 AC 69 ms
71,232 KB
testcase_27 AC 69 ms
71,276 KB
testcase_28 AC 70 ms
71,444 KB
testcase_29 AC 69 ms
71,456 KB
testcase_30 AC 69 ms
70,988 KB
testcase_31 AC 69 ms
71,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

D = dict()
now = (V[0], 0, 0, 0)
cnt = 0
D[now] = cnt
L = [(V[0], 0, 0, 0, 0)]
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]
    key = tuple(nex + [cnt%4])
    nex = tuple(nex)
    if key in D:
        N -= D[key]
        loop = cnt - D[key] + 1
        L = L[D[key]:]
        print(*L[N%loop])
        exit()
    else:
        cnt += 1
        D[key] = cnt
        L.append(nex)
        if cnt == N:
            print(*nex)
            exit()
        now = nex
0