結果

問題 No.1013 〇マス進む
ユーザー convexineqconvexineq
提出日時 2020-03-20 22:40:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,230 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 122,340 KB
最終ジャッジ日時 2023-08-21 17:44:10
合計ジャッジ時間 13,057 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,512 KB
testcase_01 AC 69 ms
71,160 KB
testcase_02 AC 69 ms
71,452 KB
testcase_03 AC 79 ms
75,784 KB
testcase_04 AC 78 ms
76,028 KB
testcase_05 AC 81 ms
76,060 KB
testcase_06 AC 80 ms
75,972 KB
testcase_07 AC 82 ms
76,036 KB
testcase_08 AC 79 ms
75,884 KB
testcase_09 AC 83 ms
76,388 KB
testcase_10 AC 82 ms
75,820 KB
testcase_11 AC 80 ms
75,720 KB
testcase_12 AC 83 ms
76,212 KB
testcase_13 AC 93 ms
76,776 KB
testcase_14 AC 139 ms
97,440 KB
testcase_15 AC 172 ms
112,148 KB
testcase_16 AC 162 ms
108,176 KB
testcase_17 AC 131 ms
94,892 KB
testcase_18 AC 141 ms
99,696 KB
testcase_19 AC 123 ms
89,616 KB
testcase_20 AC 195 ms
120,536 KB
testcase_21 AC 128 ms
93,204 KB
testcase_22 AC 149 ms
100,524 KB
testcase_23 AC 108 ms
82,704 KB
testcase_24 AC 190 ms
121,652 KB
testcase_25 AC 188 ms
120,896 KB
testcase_26 AC 106 ms
82,868 KB
testcase_27 AC 126 ms
92,412 KB
testcase_28 AC 107 ms
83,016 KB
testcase_29 AC 186 ms
120,008 KB
testcase_30 AC 123 ms
90,600 KB
testcase_31 AC 151 ms
103,920 KB
testcase_32 AC 134 ms
96,808 KB
testcase_33 AC 146 ms
97,040 KB
testcase_34 AC 173 ms
110,316 KB
testcase_35 AC 185 ms
107,744 KB
testcase_36 AC 97 ms
78,940 KB
testcase_37 AC 96 ms
78,752 KB
testcase_38 AC 183 ms
112,512 KB
testcase_39 AC 122 ms
87,460 KB
testcase_40 AC 195 ms
110,080 KB
testcase_41 AC 112 ms
83,524 KB
testcase_42 AC 142 ms
95,744 KB
testcase_43 AC 126 ms
88,216 KB
testcase_44 AC 143 ms
97,240 KB
testcase_45 AC 137 ms
94,612 KB
testcase_46 AC 116 ms
83,884 KB
testcase_47 AC 136 ms
95,644 KB
testcase_48 AC 147 ms
99,932 KB
testcase_49 AC 190 ms
109,272 KB
testcase_50 AC 165 ms
104,092 KB
testcase_51 AC 162 ms
101,052 KB
testcase_52 AC 105 ms
80,468 KB
testcase_53 AC 111 ms
82,264 KB
testcase_54 AC 172 ms
107,284 KB
testcase_55 AC 118 ms
84,428 KB
testcase_56 AC 199 ms
116,464 KB
testcase_57 AC 177 ms
103,300 KB
testcase_58 AC 234 ms
122,300 KB
testcase_59 AC 219 ms
121,944 KB
testcase_60 AC 226 ms
122,304 KB
testcase_61 AC 205 ms
122,340 KB
testcase_62 AC 186 ms
122,156 KB
testcase_63 AC 70 ms
71,380 KB
testcase_64 AC 69 ms
71,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,k,*p = [int(i) for i in read().split()]

"""
nextのテーブルを作る
Table[i][j] = j の 2**i個先
N: 要素数
MAX: 最大で何個先をみたいか
"""
def doubling_make_table(N,MAX):

    logN = len(bin(MAX))-2 #ceil(log_2(N)) 

    Table = [[-1]*N for _ in range(logN)]
    """ここを変更する"""
    Table[0] = [i+pi for i,pi in enumerate(p)]
#    for j in range(N):
#        Table[0][j] =
    #Table[1] = p[:]#[ii-1 for ii in p]
    """ここまで"""
    for i in range(1,logN):
        for j, Tiij in enumerate(Table[i-1]):
            if Tiij != -1:
                Table[i][j] = Table[i-1][Tiij%n]+(Tiij-Tiij%n)
    return Table


"""最大で何個先をみたいか:変更する"""
MAX = 10**10
BITMAX = len(bin(MAX))-2

succ = doubling_make_table(n,MAX)

"""
p の Q個先を求める
例: S^7(x) = S(S^2(S^4(x))) のように計算
"""
def getnext(p,Q):
    for k in range(BITMAX-1,-1,-1):
        if p == -1: break
        if (Q >> k) & 1: p = succ[k][p%n]+(p-p%n)
    return p

#print(len(succ),BITMAX)

for i in range(n):
    print(getnext(i,k)+1)


#print(succ[:5])

0