結果

問題 No.1935 Water Simulation
ユーザー shobonvipshobonvip
提出日時 2022-05-13 21:41:41
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 1,063 ms
使用メモリ 81,596 KB
最終ジャッジ日時 2023-02-21 18:46:07
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 119 ms
81,524 KB
testcase_01 AC 118 ms
81,596 KB
testcase_02 AC 111 ms
76,176 KB
testcase_03 AC 113 ms
76,476 KB
testcase_04 AC 109 ms
76,172 KB
testcase_05 AC 109 ms
76,296 KB
testcase_06 AC 113 ms
76,112 KB
testcase_07 AC 110 ms
76,212 KB
testcase_08 AC 111 ms
76,180 KB
testcase_09 AC 110 ms
76,204 KB
testcase_10 AC 110 ms
76,168 KB
testcase_11 AC 110 ms
76,112 KB
testcase_12 AC 111 ms
76,044 KB
testcase_13 AC 112 ms
76,092 KB
testcase_14 AC 114 ms
76,184 KB
testcase_15 AC 112 ms
76,064 KB
testcase_16 AC 111 ms
76,036 KB
testcase_17 AC 111 ms
76,084 KB
testcase_18 AC 110 ms
76,244 KB
testcase_19 AC 110 ms
76,036 KB
testcase_20 AC 111 ms
75,820 KB
testcase_21 AC 112 ms
76,164 KB
testcase_22 AC 110 ms
76,252 KB
testcase_23 AC 110 ms
75,940 KB
testcase_24 AC 111 ms
76,044 KB
testcase_25 AC 110 ms
76,172 KB
testcase_26 AC 110 ms
76,188 KB
testcase_27 AC 110 ms
76,084 KB
testcase_28 AC 110 ms
76,096 KB
testcase_29 AC 111 ms
76,176 KB
testcase_30 AC 109 ms
76,080 KB
testcase_31 AC 109 ms
75,924 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