結果

問題 No.1935 Water Simulation
ユーザー siganaisiganai
提出日時 2022-05-13 21:47:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 79,320 KB
最終ジャッジ日時 2023-09-29 06:53:35
合計ジャッジ時間 6,360 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 143 ms
79,184 KB
testcase_05 AC 143 ms
78,880 KB
testcase_06 AC 141 ms
79,044 KB
testcase_07 AC 140 ms
79,008 KB
testcase_08 AC 144 ms
78,808 KB
testcase_09 AC 142 ms
78,904 KB
testcase_10 AC 141 ms
78,640 KB
testcase_11 AC 141 ms
79,168 KB
testcase_12 AC 143 ms
78,904 KB
testcase_13 AC 141 ms
79,104 KB
testcase_14 AC 143 ms
79,032 KB
testcase_15 AC 147 ms
79,028 KB
testcase_16 AC 148 ms
79,028 KB
testcase_17 AC 144 ms
78,784 KB
testcase_18 AC 144 ms
78,808 KB
testcase_19 AC 141 ms
78,768 KB
testcase_20 AC 144 ms
79,100 KB
testcase_21 AC 145 ms
79,140 KB
testcase_22 AC 144 ms
78,808 KB
testcase_23 AC 143 ms
78,648 KB
testcase_24 AC 143 ms
78,892 KB
testcase_25 AC 141 ms
79,052 KB
testcase_26 AC 141 ms
79,096 KB
testcase_27 AC 141 ms
78,976 KB
testcase_28 AC 149 ms
79,084 KB
testcase_29 AC 144 ms
79,072 KB
testcase_30 AC 145 ms
78,812 KB
testcase_31 AC 143 ms
79,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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()
0