結果

問題 No.1935 Water Simulation
ユーザー shobonvipshobonvip
提出日時 2022-05-13 21:41:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 76,956 KB
最終ジャッジ日時 2023-09-29 09:59:22
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
76,944 KB
testcase_01 AC 105 ms
76,956 KB
testcase_02 AC 102 ms
71,580 KB
testcase_03 AC 97 ms
71,588 KB
testcase_04 AC 97 ms
71,652 KB
testcase_05 AC 97 ms
71,612 KB
testcase_06 AC 98 ms
71,376 KB
testcase_07 AC 99 ms
71,352 KB
testcase_08 AC 96 ms
71,552 KB
testcase_09 AC 98 ms
71,612 KB
testcase_10 AC 99 ms
71,724 KB
testcase_11 AC 97 ms
71,784 KB
testcase_12 AC 96 ms
71,352 KB
testcase_13 AC 99 ms
71,792 KB
testcase_14 AC 97 ms
71,812 KB
testcase_15 AC 93 ms
71,816 KB
testcase_16 AC 95 ms
71,832 KB
testcase_17 AC 96 ms
71,572 KB
testcase_18 AC 97 ms
71,676 KB
testcase_19 AC 96 ms
71,616 KB
testcase_20 AC 97 ms
71,672 KB
testcase_21 AC 98 ms
71,428 KB
testcase_22 AC 97 ms
71,356 KB
testcase_23 AC 95 ms
71,796 KB
testcase_24 AC 95 ms
71,860 KB
testcase_25 AC 98 ms
71,720 KB
testcase_26 AC 99 ms
71,888 KB
testcase_27 AC 97 ms
71,724 KB
testcase_28 AC 98 ms
71,484 KB
testcase_29 AC 97 ms
71,812 KB
testcase_30 AC 97 ms
71,612 KB
testcase_31 AC 97 ms
71,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

a,b,c,d,n = map(int,input().split())
v = [a,0,0,0]
pro = defaultdict(lambda:-1)
loop = []


tmp = " ".join([str(v[i]) for i in range(4)]+[str(3)])
loop.append(tmp)
pro[tmp] = 0

i = 0
while True:
	if i % 4 == 0:
		targ = min(v[0], b-v[1])
		v[0] -= targ
		v[1] += targ
	elif i % 4  == 1:
		targ = min(v[1], c-v[2])
		v[1] -= targ
		v[2] += targ
	elif i % 4 == 2:
		targ = min(v[2], d-v[3])
		v[2] -= targ
		v[3] += targ
	else:
		targ = min(v[3], a-v[0])
		v[3] -= targ
		v[0] += targ
	tmp = " ".join([str(v[i]) for i in range(4)]+[str(i%4)])
	if pro[tmp] >= 0:
		rep = i+1 - pro[tmp]
		ind = pro[tmp]
		break
	pro[tmp] = i+1
	loop.append(tmp)
	i += 1

#print(loop)

if n < ind:
	print(*loop[n].split()[:4])
else:
	print(*loop[ind + (n-ind)%rep].split()[:4])
0