結果

問題 No.1935 Water Simulation
ユーザー googol_S0googol_S0
提出日時 2022-05-13 22:08:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 76,344 KB
最終ジャッジ日時 2023-09-29 10:01:40
合計ジャッジ時間 4,152 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,344 KB
testcase_01 AC 83 ms
76,160 KB
testcase_02 AC 76 ms
71,220 KB
testcase_03 AC 80 ms
75,632 KB
testcase_04 AC 77 ms
71,256 KB
testcase_05 AC 80 ms
71,060 KB
testcase_06 AC 78 ms
71,220 KB
testcase_07 AC 76 ms
71,120 KB
testcase_08 AC 77 ms
71,168 KB
testcase_09 AC 77 ms
71,396 KB
testcase_10 AC 76 ms
71,160 KB
testcase_11 AC 76 ms
71,192 KB
testcase_12 AC 76 ms
71,128 KB
testcase_13 AC 75 ms
71,356 KB
testcase_14 AC 77 ms
70,924 KB
testcase_15 AC 76 ms
71,016 KB
testcase_16 AC 80 ms
71,120 KB
testcase_17 AC 78 ms
71,220 KB
testcase_18 AC 77 ms
71,220 KB
testcase_19 AC 77 ms
71,012 KB
testcase_20 AC 77 ms
71,224 KB
testcase_21 AC 76 ms
71,004 KB
testcase_22 AC 76 ms
71,140 KB
testcase_23 AC 78 ms
71,340 KB
testcase_24 AC 77 ms
71,140 KB
testcase_25 AC 77 ms
71,392 KB
testcase_26 AC 75 ms
71,252 KB
testcase_27 AC 77 ms
71,172 KB
testcase_28 AC 78 ms
71,328 KB
testcase_29 AC 79 ms
71,124 KB
testcase_30 AC 78 ms
71,172 KB
testcase_31 AC 80 ms
71,196 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