結果

問題 No.1935 Water Simulation
ユーザー abababab
提出日時 2022-05-14 00:37:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-09-29 10:44:30
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,548 KB
testcase_01 AC 20 ms
8,584 KB
testcase_02 AC 19 ms
8,576 KB
testcase_03 AC 19 ms
8,640 KB
testcase_04 AC 19 ms
8,504 KB
testcase_05 AC 19 ms
8,624 KB
testcase_06 AC 19 ms
8,536 KB
testcase_07 AC 19 ms
8,516 KB
testcase_08 AC 20 ms
8,580 KB
testcase_09 AC 19 ms
8,584 KB
testcase_10 AC 19 ms
8,568 KB
testcase_11 AC 19 ms
8,568 KB
testcase_12 AC 19 ms
8,592 KB
testcase_13 AC 19 ms
8,512 KB
testcase_14 AC 19 ms
8,508 KB
testcase_15 AC 19 ms
8,516 KB
testcase_16 AC 19 ms
8,584 KB
testcase_17 AC 19 ms
8,640 KB
testcase_18 AC 19 ms
8,496 KB
testcase_19 AC 19 ms
8,580 KB
testcase_20 AC 18 ms
8,512 KB
testcase_21 AC 19 ms
8,640 KB
testcase_22 AC 19 ms
8,516 KB
testcase_23 AC 19 ms
8,584 KB
testcase_24 AC 19 ms
8,600 KB
testcase_25 AC 19 ms
8,500 KB
testcase_26 AC 19 ms
8,500 KB
testcase_27 AC 19 ms
8,508 KB
testcase_28 AC 19 ms
8,496 KB
testcase_29 AC 19 ms
8,536 KB
testcase_30 AC 19 ms
8,588 KB
testcase_31 AC 19 ms
8,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import count

*V, n = map(int, input().split())

now = [0] * 5
now[0] = V[0]

idx = defaultdict(lambda : -1)
route = []

for i in count():
    idx[tuple(now)] = i
    route.append(now[:4])

    l, r = i % 4, (i + 1) % 4
    move = min(now[l], V[r] - now[r])
    now[l] -= move
    now[r] += move
    now[4] = (now[4] + 1) % 4 

    if tuple(now) in idx:
        break

loop = idx[tuple(now)]

if n < loop:
    print(*route[n])
else:
    route = route[loop:]
    n -= loop
    print(*route[n % len(route)])
0