結果
| 問題 |
No.1935 Water Simulation
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-06-07 12:30:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 802 bytes |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 82,252 KB |
| 実行使用メモリ | 61,464 KB |
| 最終ジャッジ日時 | 2024-12-29 17:45:47 |
| 合計ジャッジ時間 | 2,959 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
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
rlangevin