結果
問題 | No.1935 Water Simulation |
ユーザー |
|
提出日時 | 2022-05-13 23:36:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 58,368 KB |
最終ジャッジ日時 | 2024-07-22 04:37:59 |
合計ジャッジ時間 | 2,445 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
v1, v2, v3, v4, N = map(int, input().split())def next_status(status):a, b, c, d, t = statusif t == 0:if a > v2 - b:a, b = a + b - v2, v2else:a, b = 0, a + belif t == 1:if b > v3 - c:b, c = b + c - v3, v3else:b, c = 0, b + celif t == 2:if c > v4 - d:c, d = c + d - v4, v4else:c, d = 0, c + delse:if d > v1 - a:d, a = d + a - v1, v1else:d, a = 0, a + dreturn (a, b, c, d, (t + 1) % 4)def solve(N):dic = dict()status = (v1, 0, 0, 0, 0)hist = [status]turn = 0while status not in dic:dic[status] = turnstatus = next_status(status)hist.append(status)turn += 1if turn == N:return statushead = dic[status]cycle = turn - headans = (N - head) % cyclereturn hist[head + ans]a, b, c, d, t = solve(N)print(a, b, c, d)