結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 101 ms
77,920 KB
testcase_05 AC 101 ms
82,052 KB
testcase_06 AC 103 ms
83,996 KB
testcase_07 AC 106 ms
79,080 KB
testcase_08 AC 102 ms
79,320 KB
testcase_09 AC 103 ms
82,848 KB
testcase_10 AC 103 ms
82,052 KB
testcase_11 AC 102 ms
78,520 KB
testcase_12 AC 97 ms
73,164 KB
testcase_13 AC 100 ms
73,244 KB
testcase_14 AC 101 ms
77,508 KB
testcase_15 AC 105 ms
80,512 KB
testcase_16 AC 104 ms
79,652 KB
testcase_17 AC 101 ms
78,384 KB
testcase_18 AC 99 ms
73,244 KB
testcase_19 AC 105 ms
84,804 KB
testcase_20 AC 98 ms
76,824 KB
testcase_21 AC 97 ms
80,204 KB
testcase_22 AC 102 ms
80,884 KB
testcase_23 AC 99 ms
77,304 KB
testcase_24 AC 101 ms
83,820 KB
testcase_25 AC 98 ms
83,236 KB
testcase_26 AC 96 ms
76,980 KB
testcase_27 AC 95 ms
77,804 KB
testcase_28 AC 97 ms
77,452 KB
testcase_29 AC 94 ms
73,028 KB
testcase_30 AC 98 ms
73,200 KB
testcase_31 AC 100 ms
77,072 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(60):
    if (n>>k) & 1:
        now = doubling[k][now]
        n-= (1<<k)
print(*memo[now])
0