結果

問題 No.1935 Water Simulation
ユーザー rpy3cpprpy3cpp
提出日時 2022-05-13 23:36:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 75,188 KB
最終ジャッジ日時 2023-09-29 10:04:25
合計ジャッジ時間 3,863 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,168 KB
testcase_01 AC 73 ms
75,188 KB
testcase_02 AC 70 ms
71,156 KB
testcase_03 AC 69 ms
71,352 KB
testcase_04 AC 73 ms
71,576 KB
testcase_05 AC 71 ms
71,424 KB
testcase_06 AC 68 ms
71,304 KB
testcase_07 AC 69 ms
71,136 KB
testcase_08 AC 68 ms
71,280 KB
testcase_09 AC 70 ms
71,280 KB
testcase_10 AC 68 ms
71,448 KB
testcase_11 AC 72 ms
71,332 KB
testcase_12 AC 75 ms
71,584 KB
testcase_13 AC 71 ms
71,384 KB
testcase_14 AC 72 ms
71,192 KB
testcase_15 AC 72 ms
71,256 KB
testcase_16 AC 69 ms
71,316 KB
testcase_17 AC 71 ms
71,092 KB
testcase_18 AC 70 ms
71,388 KB
testcase_19 AC 69 ms
71,532 KB
testcase_20 AC 68 ms
71,568 KB
testcase_21 AC 69 ms
71,316 KB
testcase_22 AC 68 ms
71,136 KB
testcase_23 AC 69 ms
71,400 KB
testcase_24 AC 71 ms
71,560 KB
testcase_25 AC 70 ms
71,240 KB
testcase_26 AC 70 ms
71,496 KB
testcase_27 AC 69 ms
71,392 KB
testcase_28 AC 73 ms
71,244 KB
testcase_29 AC 73 ms
71,316 KB
testcase_30 AC 70 ms
71,356 KB
testcase_31 AC 74 ms
71,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

v1, v2, v3, v4, N = map(int, input().split())

def next_status(status):
    a, b, c, d, t = status
    if t == 0:
        if a > v2 - b:
            a, b = a + b - v2, v2
        else:
            a, b = 0, a + b
    elif t == 1:
        if b > v3 - c:
            b, c = b + c - v3, v3
        else:
            b, c = 0, b + c
    elif t == 2:
        if c > v4 - d:
            c, d = c + d - v4, v4
        else:
            c, d = 0, c + d
    else:
        if d > v1 - a:
            d, a = d + a - v1, v1
        else:
            d, a = 0, a + d
    return (a, b, c, d, (t + 1) % 4)

def solve(N):
    dic = dict()
    status = (v1, 0, 0, 0, 0)
    hist = [status]
    turn = 0
    while status not in dic:
        dic[status] = turn
        status = next_status(status)
        hist.append(status)
        turn += 1
        if turn == N:
            return status
    head = dic[status]
    cycle = turn - head
    ans = (N - head) % cycle
    return hist[head + ans]

a, b, c, d, t = solve(N)
print(a, b, c, d)
0