結果
| 問題 | No.1935 Water Simulation |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-06-07 12:30:47 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 802 bytes |
| 記録 | |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 60,416 KB |
| 最終ジャッジ日時 | 2026-06-03 11:55:27 |
| 合計ジャッジ時間 | 2,260 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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