結果
問題 | No.1935 Water Simulation |
ユーザー |
|
提出日時 | 2022-05-13 22:15:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 714 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,156 KB |
実行使用メモリ | 61,868 KB |
最終ジャッジ日時 | 2024-07-22 04:28:33 |
合計ジャッジ時間 | 2,986 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 1 |
ソースコード
from collections import defaultdict v1, v2, v3, v4, N = map(int, input().split()) V = [v1, v2, v3, v4] start = (v1, 0, 0, 0, 0) dist = defaultdict(lambda: -1) status = defaultdict(tuple) now = start d, pt = 0, 0 while dist[now] == -1: dist[now] = d status[d] = now next = list(now) delta = min((V[(pt + 1) % 4] - now[(pt + 1) % 4]), now[pt]) next[pt] -= delta next[(pt + 1) % 4] += delta next[-1] = (next[-1] + 1) % 4 d, pt = d + 1, (pt + 1) % 4 now = tuple(next) # print(now) # print(d) cycle_length = d - dist[now] # print(cycle_length) if N < d: exit(print(*status[d-1][:-1])) N -= d - cycle_length N %= cycle_length print(*status[(d - cycle_length + N)][:-1])