結果
問題 |
No.1935 Water Simulation
|
ユーザー |
![]() |
提出日時 | 2022-05-13 21:47:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,057 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 66,020 KB |
最終ジャッジ日時 | 2024-07-22 01:26:36 |
合計ジャッジ時間 | 3,314 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 4 |
ソースコード
#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect from heapq import * import functools mod=998244353 import sys input=sys.stdin.readline v1,v2,v3,v4,n=map(int,input().split()) d = defaultdict(lambda: -1) cnt = 0 d[(v1,0,0,0)] = 0 n4=n2=n3=0;n1=v1 while cnt < n: if cnt % 4 == 0: dis = min(v2 - n2,n1) n1 -= dis n2 += dis elif cnt % 4 == 1: dis = min(v3-n3,n2) n2 -= dis n3 += dis elif cnt % 4 == 2: dis = min(v4 - n4,n3) n3 -= dis n4 += dis else: dis = min(v1-n1,n4) n4 -= dis n1 += dis cnt += 1 if d[(n1,n2,n3,n4)] == -1: d[(n1,n2,n3,n4)] = cnt else: loop = cnt - d[(n1,n2,n3,n4)] break if cnt == n: print(n1,n2,n3,n4) else: rem = d[(n1,n2,n3,n4)] p = (n - rem) % loop + rem for key,value in d.items(): if value == p: print(*key) exit()