結果

問題 No.1013 〇マス進む
ユーザー akasia_midoriakasia_midori
提出日時 2022-08-21 09:32:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,330 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 137,288 KB
最終ジャッジ日時 2024-04-18 09:07:46
合計ジャッジ時間 11,399 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,240 KB
testcase_01 AC 35 ms
52,728 KB
testcase_02 AC 36 ms
53,036 KB
testcase_03 AC 53 ms
63,460 KB
testcase_04 AC 49 ms
64,196 KB
testcase_05 AC 55 ms
67,204 KB
testcase_06 AC 55 ms
66,360 KB
testcase_07 AC 52 ms
66,508 KB
testcase_08 AC 53 ms
66,284 KB
testcase_09 AC 52 ms
64,960 KB
testcase_10 AC 53 ms
66,856 KB
testcase_11 AC 55 ms
67,600 KB
testcase_12 AC 54 ms
66,136 KB
testcase_13 AC 60 ms
70,156 KB
testcase_14 AC 138 ms
104,604 KB
testcase_15 AC 179 ms
123,224 KB
testcase_16 AC 185 ms
119,016 KB
testcase_17 AC 118 ms
101,020 KB
testcase_18 AC 145 ms
106,728 KB
testcase_19 AC 97 ms
91,572 KB
testcase_20 AC 203 ms
134,480 KB
testcase_21 AC 123 ms
98,792 KB
testcase_22 AC 147 ms
107,872 KB
testcase_23 AC 76 ms
81,440 KB
testcase_24 AC 238 ms
136,560 KB
testcase_25 AC 206 ms
135,204 KB
testcase_26 AC 80 ms
81,916 KB
testcase_27 AC 105 ms
97,292 KB
testcase_28 AC 78 ms
81,284 KB
testcase_29 AC 215 ms
133,912 KB
testcase_30 AC 115 ms
94,984 KB
testcase_31 AC 163 ms
113,016 KB
testcase_32 AC 132 ms
103,720 KB
testcase_33 AC 128 ms
103,132 KB
testcase_34 AC 193 ms
120,660 KB
testcase_35 AC 192 ms
117,744 KB
testcase_36 AC 59 ms
69,484 KB
testcase_37 AC 59 ms
70,244 KB
testcase_38 AC 206 ms
124,552 KB
testcase_39 AC 102 ms
87,864 KB
testcase_40 AC 213 ms
120,480 KB
testcase_41 AC 84 ms
81,436 KB
testcase_42 AC 136 ms
101,516 KB
testcase_43 AC 121 ms
91,764 KB
testcase_44 AC 142 ms
103,392 KB
testcase_45 AC 129 ms
99,856 KB
testcase_46 AC 86 ms
83,148 KB
testcase_47 AC 129 ms
101,308 KB
testcase_48 AC 150 ms
106,744 KB
testcase_49 AC 204 ms
119,280 KB
testcase_50 AC 164 ms
113,008 KB
testcase_51 AC 156 ms
108,652 KB
testcase_52 AC 67 ms
74,432 KB
testcase_53 AC 81 ms
84,028 KB
testcase_54 AC 171 ms
117,184 KB
testcase_55 AC 89 ms
82,620 KB
testcase_56 AC 222 ms
129,148 KB
testcase_57 AC 183 ms
111,836 KB
testcase_58 AC 275 ms
136,880 KB
testcase_59 AC 255 ms
137,104 KB
testcase_60 AC 245 ms
137,288 KB
testcase_61 AC 203 ms
137,040 KB
testcase_62 AC 191 ms
137,224 KB
testcase_63 AC 36 ms
52,124 KB
testcase_64 AC 36 ms
52,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def oi(): return int(input())
def os(): return input()
def mi(): return list(map(int, input().split()))

# import sys
# input = sys.stdin.readline
# import sys
# sys.setrecursionlimit(10**8)
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')

input_count = 0

N, K = mi()
A = mi()

# 最大操作回数よりも大きい2^LOGのLOGをいれる
LOG = 30

# ダブリングのテーブル
dp = [[0 for j in range(N)] for i in range(LOG)]
dp_sum = [[0 for j in range(N)] for i in range(LOG)]  # 加算していくタイプ用

# 初期条件
for i in range(N):
    # 初期の遷移を全て網羅することで2^i回目でも遷移できるようにする
    dp[0][i] = (A[i]+i)%N
    dp_sum[0][i] = A[i]  # 加算していくタイプ用

# 遷移(2のベキ回)
for i in range(1, LOG):
    for j in range(N):
        ind = dp[i - 1][j]
        dp[i][j] = dp[i - 1][ind]

        ind_dp_val = dp_sum[i - 1][j] # 加算していくタイプ用
        dp_sum[i][j] = dp_sum[i - 1][ind] + ind_dp_val # 加算していくタイプ用



# 解を求める

K2 = K
for answer in range(N):
    i = 0
    out = answer+1#A[answer]
    K = K2
    while K:
        if K & 1:
            out += dp_sum[i][answer] # 加算していくタイプ用
            answer = dp[i][answer]
        K >>= 1
        i += 1

    print(out)
0