結果

問題 No.1935 Water Simulation
ユーザー ああああ
提出日時 2022-12-28 12:19:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-08-15 06:55:41
合計ジャッジ時間 4,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
76,096 KB
testcase_01 AC 88 ms
76,148 KB
testcase_02 AC 83 ms
71,500 KB
testcase_03 AC 86 ms
71,392 KB
testcase_04 AC 84 ms
71,452 KB
testcase_05 AC 81 ms
71,504 KB
testcase_06 AC 83 ms
71,212 KB
testcase_07 AC 86 ms
71,568 KB
testcase_08 AC 83 ms
71,484 KB
testcase_09 AC 85 ms
71,480 KB
testcase_10 AC 83 ms
71,484 KB
testcase_11 AC 82 ms
71,244 KB
testcase_12 AC 84 ms
71,392 KB
testcase_13 AC 85 ms
71,204 KB
testcase_14 AC 84 ms
71,340 KB
testcase_15 AC 82 ms
71,160 KB
testcase_16 AC 83 ms
71,452 KB
testcase_17 AC 83 ms
71,036 KB
testcase_18 AC 83 ms
71,216 KB
testcase_19 AC 84 ms
71,208 KB
testcase_20 AC 88 ms
71,504 KB
testcase_21 AC 84 ms
71,212 KB
testcase_22 AC 87 ms
71,668 KB
testcase_23 AC 85 ms
71,392 KB
testcase_24 AC 85 ms
71,580 KB
testcase_25 AC 81 ms
71,484 KB
testcase_26 AC 86 ms
71,056 KB
testcase_27 AC 84 ms
71,344 KB
testcase_28 AC 86 ms
71,488 KB
testcase_29 AC 81 ms
71,212 KB
testcase_30 AC 81 ms
71,576 KB
testcase_31 AC 82 ms
71,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
V1,V2,V3,V4,N=map(int,input().split())

youseki=[V1,V2,V3,V4]
V=[V1,0,0,0]
link=[(V1,0,0,0,0)]
s=set()
s.add((V1,0,0,0,0))
index=0
d=defaultdict(int)
d[(V1,0,0,0,0)]=index
check=True
while(check):
    for i in range(4):
        if youseki[(i+1)%4]-V[(i+1)%4]<=V[i]:
            V[i]-=youseki[(i+1)%4]-V[(i+1)%4]
            V[(i+1)%4]=youseki[(i+1)%4]
        else:
            V[(i+1)%4]+=V[i]
            V[i]=0
        index+=1
        tplV=tuple([V[0],V[1],V[2],V[3],index%4])
        if tplV in s:
            check=False
            break
        s.add(tplV)
        link.append(tplV)
        d[tplV]=index

lastV=tplV
if index>N:
    print(*link[N][:4])
else:
    N-=d[lastV]
    print(*link[d[lastV]+N%(index-d[lastV])][:4])
0