結果

問題 No.1935 Water Simulation
ユーザー misonikomipanmisonikomipan
提出日時 2022-05-13 21:53:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,512 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 101,020 KB
最終ジャッジ日時 2023-09-29 07:03:12
合計ジャッジ時間 14,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 358 ms
100,520 KB
testcase_05 AC 357 ms
100,696 KB
testcase_06 AC 361 ms
100,636 KB
testcase_07 AC 356 ms
100,812 KB
testcase_08 AC 354 ms
100,808 KB
testcase_09 AC 360 ms
100,368 KB
testcase_10 AC 360 ms
100,764 KB
testcase_11 AC 357 ms
100,356 KB
testcase_12 AC 353 ms
100,672 KB
testcase_13 AC 351 ms
100,728 KB
testcase_14 AC 350 ms
100,756 KB
testcase_15 AC 350 ms
100,368 KB
testcase_16 AC 350 ms
100,692 KB
testcase_17 AC 354 ms
100,640 KB
testcase_18 AC 349 ms
100,604 KB
testcase_19 AC 361 ms
100,776 KB
testcase_20 AC 358 ms
100,604 KB
testcase_21 AC 358 ms
100,252 KB
testcase_22 AC 356 ms
100,600 KB
testcase_23 AC 359 ms
100,756 KB
testcase_24 AC 359 ms
100,360 KB
testcase_25 AC 356 ms
100,728 KB
testcase_26 AC 353 ms
100,756 KB
testcase_27 AC 349 ms
100,700 KB
testcase_28 AC 349 ms
100,636 KB
testcase_29 AC 351 ms
100,640 KB
testcase_30 AC 352 ms
100,588 KB
testcase_31 AC 352 ms
100,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import nntplib
import sys
import math
import heapq
from collections import deque, Counter, defaultdict
from sys import stdin



INF = 10 ** 7
int1 = lambda x: int(x) - 1
stinput = lambda: stdin.readline()[:-1]
ii = lambda: int(stinput())  # int input
mi = lambda: map(int, stdin.readline().split())  # map input (int)
li = lambda: list(mi())  # list input (int)
mi1 = lambda: map(int1, stdin.readline().split())  # map input (int)-1
li1 = lambda: list(mi1())  # list input (int)-1
mis = lambda: map(str, stdin.readline().split())  # map input (string)
lis = lambda: list(mis())  # list input (string)


*V, N = mi()

nV = [V[i] if not(i) else 0 for i in range(4)]
d = {(V[0], 0, 0, 0): 0}
d2 = {0: (V[0], 0, 0, 0)}
for n in range(N):
    pV = [nV[i] for i in range(4)]
    if n % 4 == 0:
        nV[1] = min(V[1], pV[1] + pV[0])
        nV[0] = pV[0] - (nV[1] - pV[1])
    elif n % 4 == 1:
        nV[2] = min(V[2], pV[2] + pV[1])
        nV[1] = pV[1] - (nV[2] - pV[2])
    elif n % 4 == 2:
        nV[3] = min(V[3], pV[3] + pV[2])
        nV[2] = pV[2] - (nV[3] - pV[3])
    else:
        nV[0] = min(V[0], pV[0] + pV[3])
        nV[3] = pV[3] - (nV[0] - pV[0])
    tnV = tuple(nV)
    if tnV in d:
        d[(N, N, N, N)] = n + 1
        d2[n + 1] = tnV
        roopStart = d[tnV]
        roopEnd = n + 1
        a = nV
        break
    else: 
        d[tnV] = n + 1
        d2[n + 1] = tnV
    if n == N - 1: 
        print(*nV)
        exit()
print(*d2[roopStart + (N - roopStart) % (roopEnd - roopStart)])
0