結果

問題 No.1935 Water Simulation
ユーザー rin204rin204
提出日時 2022-05-13 21:29:01
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 521 ms
使用メモリ 75,832 KB
最終ジャッジ日時 2023-02-21 18:44:08
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 84 ms
75,740 KB
testcase_01 AC 83 ms
75,696 KB
testcase_02 AC 83 ms
75,428 KB
testcase_03 AC 83 ms
75,744 KB
testcase_04 AC 82 ms
75,624 KB
testcase_05 AC 85 ms
75,788 KB
testcase_06 AC 83 ms
75,832 KB
testcase_07 AC 83 ms
75,804 KB
testcase_08 AC 84 ms
75,424 KB
testcase_09 AC 87 ms
75,784 KB
testcase_10 AC 84 ms
75,500 KB
testcase_11 AC 87 ms
75,468 KB
testcase_12 AC 84 ms
75,484 KB
testcase_13 AC 83 ms
75,504 KB
testcase_14 AC 82 ms
75,424 KB
testcase_15 AC 82 ms
75,720 KB
testcase_16 AC 83 ms
75,736 KB
testcase_17 AC 83 ms
75,720 KB
testcase_18 AC 82 ms
75,644 KB
testcase_19 AC 88 ms
75,488 KB
testcase_20 AC 85 ms
75,708 KB
testcase_21 AC 82 ms
75,712 KB
testcase_22 AC 84 ms
75,708 KB
testcase_23 AC 83 ms
75,544 KB
testcase_24 AC 82 ms
75,476 KB
testcase_25 AC 83 ms
75,712 KB
testcase_26 AC 84 ms
75,620 KB
testcase_27 AC 89 ms
75,740 KB
testcase_28 AC 83 ms
75,724 KB
testcase_29 AC 85 ms
75,464 KB
testcase_30 AC 82 ms
75,548 KB
testcase_31 AC 82 ms
75,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A = [V[0], 0, 0, 0]

def f(p1):
    p2 = (p1 + 1) % 4
    if A[p1] + A[p2] <= V[p2]:
        A[p2] += A[p1]
        A[p1] = 0
    else:
        A[p1] = A[p1] + A[p2] - V[p2]
        A[p2] = V[p2]

def g():
    return ((A[0] * 110 + A[1]) * 110 + A[2]) * 110 + A[3]

se = set()
for i in range(n):
    if i % 4 == 0:
        x = g()
        if x in se:
            for i in range(n % 4):
                f(i)
            break
        else:
            se.add(x)
    f(i % 4)
    

print(*A)

0