結果

問題 No.1935 Water Simulation
ユーザー googol_S0googol_S0
提出日時 2022-05-13 22:08:47
言語 PyPy3
(7.9.16)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 796 ms
実行使用メモリ 80,852 KB
最終ジャッジ日時 2023-02-21 18:50:36
合計ジャッジ時間 5,391 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
80,852 KB
testcase_01 AC 95 ms
80,608 KB
testcase_02 AC 88 ms
75,460 KB
testcase_03 AC 91 ms
80,468 KB
testcase_04 AC 87 ms
75,684 KB
testcase_05 AC 89 ms
75,720 KB
testcase_06 AC 90 ms
75,712 KB
testcase_07 AC 89 ms
75,360 KB
testcase_08 AC 88 ms
75,732 KB
testcase_09 AC 89 ms
75,508 KB
testcase_10 AC 88 ms
75,460 KB
testcase_11 AC 87 ms
75,676 KB
testcase_12 AC 88 ms
75,276 KB
testcase_13 AC 89 ms
75,864 KB
testcase_14 AC 89 ms
75,392 KB
testcase_15 AC 88 ms
75,460 KB
testcase_16 AC 90 ms
75,392 KB
testcase_17 AC 90 ms
75,392 KB
testcase_18 AC 89 ms
75,840 KB
testcase_19 AC 89 ms
75,500 KB
testcase_20 AC 89 ms
75,660 KB
testcase_21 AC 89 ms
75,288 KB
testcase_22 AC 90 ms
75,728 KB
testcase_23 AC 90 ms
75,816 KB
testcase_24 AC 91 ms
75,676 KB
testcase_25 AC 89 ms
75,516 KB
testcase_26 AC 90 ms
75,604 KB
testcase_27 AC 89 ms
75,392 KB
testcase_28 AC 89 ms
75,396 KB
testcase_29 AC 89 ms
75,696 KB
testcase_30 AC 89 ms
75,564 KB
testcase_31 AC 90 ms
75,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A,B,C,D,N=map(int,input().split())
V=[A,B,C,D]
S=set()
D=dict()
X=[-1]
Y=[]
def f(a,b,c,d):
  v=min(a+b,d)
  w=v-b
  return (a-w,v)

def dfs(x):
  if x in S:
    return D[x]
  D[x]=len(S)
  S.add(x)
  Y.append(x)
  i=x[4]
  y=[x[0],x[1],x[2],x[3],(i+1)&3]
  y[i],y[(i+1)&3]=f(y[i],y[(i+1)&3],V[i],V[(i+1)&3])
  y=tuple(y)
  v=len(S)-1
  X.append(-1)
  X[v]=dfs(y)
  return v

dfs((A,0,0,0,0))
del X[-1]
M=N
N=len(X)
P=[[-1]*N for i in range(62)]
for i in range(N):
  P[0][i]=X[i]
for i in range(61):
  for j in range(N):
    P[i+1][j]=P[i][P[i][j]]
v=0
for i in range(62):
  if (M>>i)&1:
    v=P[i][v]
print(*Y[v][:4])
0