結果

問題 No.1935 Water Simulation
ユーザー lilictakalilictaka
提出日時 2022-05-14 15:20:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,620 KB
実行使用メモリ 85,076 KB
最終ジャッジ日時 2023-09-30 06:57:17
合計ジャッジ時間 5,773 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 97 ms
77,908 KB
testcase_05 AC 97 ms
81,912 KB
testcase_06 AC 100 ms
83,840 KB
testcase_07 AC 101 ms
78,996 KB
testcase_08 AC 101 ms
79,364 KB
testcase_09 AC 103 ms
82,840 KB
testcase_10 AC 101 ms
82,092 KB
testcase_11 AC 101 ms
78,012 KB
testcase_12 AC 94 ms
73,256 KB
testcase_13 AC 93 ms
73,240 KB
testcase_14 AC 96 ms
77,504 KB
testcase_15 AC 99 ms
80,196 KB
testcase_16 AC 100 ms
79,832 KB
testcase_17 AC 105 ms
77,980 KB
testcase_18 AC 96 ms
73,120 KB
testcase_19 AC 104 ms
85,076 KB
testcase_20 AC 96 ms
76,860 KB
testcase_21 AC 103 ms
80,564 KB
testcase_22 AC 100 ms
80,652 KB
testcase_23 AC 101 ms
77,304 KB
testcase_24 AC 103 ms
84,232 KB
testcase_25 AC 105 ms
83,244 KB
testcase_26 AC 98 ms
76,648 KB
testcase_27 AC 100 ms
77,776 KB
testcase_28 AC 97 ms
77,680 KB
testcase_29 AC 93 ms
73,252 KB
testcase_30 AC 95 ms
73,212 KB
testcase_31 AC 98 ms
77,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import copy
from collections import defaultdict,deque
v1,v2,v3,v4,n = map(int,input().split())
volume = [v1,v2,v3,v4]
tmp = [v1,0,0,0]
dp = [-1 for _ in range((v1+1) ** 3)]
def convert(x,y,z,X,Y,Z):
    return X * Y *z + X * y + x
def ch(List):
    v1,v2,v3,v4 = List
    return convert(v1,v2,v3,volume[0]+1,volume[0]+1,volume[0]+1)
q = deque()
q.append((tmp,0))
dp[ch(tmp)] = 0
memo = []
cycle = -1
while q:
    board,t = q.popleft()
    memo.append(board)
    new = copy(board)
    co = volume[(t+1)%4] -new[(t+1) % 4]
    new[(t+1) % 4] += min(new[t%4],co)
    new[t%4] -= min(new[t%4],co)
    if dp[ch(new)] >= 0:
        cycle = dp[ch(new)]
        break
    q.append((new,t+1))
    dp[ch(new)] = dp[ch(board)] +1
doubling = [[-1] * len(memo) for _ in range(61)]
for i in range(len(memo)):
    if i == len(memo) -1:
        doubling[0][i] = cycle
    else:
        doubling[0][i] = i + 1
for k in range(60):
    for i in range(len(memo)):
        doubling[k+1][i] = doubling[k][doubling[k][i]]
now = 0
for k in range(61):
    if (n>>k) & 1:
        now = doubling[k][now]
        n-= (1<<k)
print(*memo[now])
0