結果
問題 | No.1013 〇マス進む |
ユーザー | toyuzuko |
提出日時 | 2023-01-20 18:04:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,008 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 97,528 KB |
最終ジャッジ日時 | 2024-06-23 06:48:38 |
合計ジャッジ時間 | 12,571 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
67,328 KB |
testcase_01 | AC | 68 ms
66,816 KB |
testcase_02 | AC | 68 ms
67,072 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 89 ms
74,240 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 164 ms
96,952 KB |
testcase_63 | AC | 70 ms
66,944 KB |
testcase_64 | WA | - |
ソースコード
from typing import List, Generic, Optional, Callable, TypeVar S = TypeVar('S') class FunctionalGraph(Generic[S]): def __init__(self, n: int, edge_to: List[S], node_val: Optional[List[S]] = None, op: Callable[[int, int], int] = lambda fr, to: to) -> None: if node_val is None: node_val = list(range(n)) self.n = n self.edge_to = edge_to self.node_val = node_val self.op = op self.built = False def build_doubling(self, bit_max: int = 31): self.built = True self.bit_max = bit_max self.dub = [[-1] * self.n for _ in range(self.bit_max)] self.dp = [[-1] * self.n for _ in range(self.bit_max)] for i in range(self.n): self.dub[0][i] = self.edge_to[i] self.dp[0][i] = self.node_val[i] # node_valを1回移動後の値にする? for i in range(1, self.bit_max): for j in range(self.n): if self.dub[i - 1][j] != -1: self.dub[i][j] = self.dub[i - 1][self.dub[i - 1][j]] self.dp[i][j] = self.op(self.dp[i - 1][j], self.dp[i - 1][self.dub[i - 1][j]]) def get(self, v: int, k: int) -> int: if not self.built: self.build_doubling() for i in range(self.bit_max): if k & (1 << i): v = self.dub[i][v] return v def prod(self, v: int, k: int) -> S: if not self.built: self.build_doubling() res = v # 要修正! for i in range(self.bit_max): if k & (1 << i): res = self.op(res, self.dp[i][v]) v = self.dub[i][v] return res N, K = map(int, input().split()) P = list(map(int, input().split())) edge_to = [(i + P[i]) % N for i in range(N)] node_val = [0] * N for i in range(N): node_val[i] = i + P[i] def op(fr, to): return to + fr // N * N F = FunctionalGraph(N, edge_to, node_val, op) F.build_doubling(4) for i in range(N): res = F.prod(i, K) print(res + 1)