結果

問題 No.1013 〇マス進む
ユーザー convexineqconvexineq
提出日時 2020-03-20 22:40:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 1,230 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 120,832 KB
最終ジャッジ日時 2024-05-08 23:12:50
合計ジャッジ時間 10,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,224 KB
testcase_01 AC 43 ms
52,352 KB
testcase_02 AC 39 ms
52,480 KB
testcase_03 AC 51 ms
61,184 KB
testcase_04 AC 48 ms
59,648 KB
testcase_05 AC 51 ms
60,800 KB
testcase_06 AC 52 ms
60,800 KB
testcase_07 AC 53 ms
61,568 KB
testcase_08 AC 51 ms
60,800 KB
testcase_09 AC 55 ms
62,976 KB
testcase_10 AC 54 ms
61,824 KB
testcase_11 AC 50 ms
61,184 KB
testcase_12 AC 55 ms
62,720 KB
testcase_13 AC 68 ms
70,656 KB
testcase_14 AC 119 ms
96,512 KB
testcase_15 AC 159 ms
110,464 KB
testcase_16 AC 148 ms
107,136 KB
testcase_17 AC 115 ms
93,824 KB
testcase_18 AC 126 ms
98,560 KB
testcase_19 AC 105 ms
88,448 KB
testcase_20 AC 178 ms
118,912 KB
testcase_21 AC 113 ms
91,904 KB
testcase_22 AC 133 ms
99,200 KB
testcase_23 AC 89 ms
81,536 KB
testcase_24 AC 173 ms
120,064 KB
testcase_25 AC 173 ms
119,424 KB
testcase_26 AC 89 ms
81,664 KB
testcase_27 AC 107 ms
91,136 KB
testcase_28 AC 89 ms
81,920 KB
testcase_29 AC 173 ms
118,272 KB
testcase_30 AC 106 ms
89,472 KB
testcase_31 AC 137 ms
102,912 KB
testcase_32 AC 117 ms
95,872 KB
testcase_33 AC 124 ms
96,000 KB
testcase_34 AC 161 ms
109,056 KB
testcase_35 AC 171 ms
106,496 KB
testcase_36 AC 75 ms
73,472 KB
testcase_37 AC 73 ms
72,832 KB
testcase_38 AC 170 ms
111,232 KB
testcase_39 AC 103 ms
86,400 KB
testcase_40 AC 181 ms
108,672 KB
testcase_41 AC 101 ms
81,920 KB
testcase_42 AC 127 ms
94,464 KB
testcase_43 AC 111 ms
87,040 KB
testcase_44 AC 128 ms
96,000 KB
testcase_45 AC 122 ms
93,568 KB
testcase_46 AC 97 ms
82,560 KB
testcase_47 AC 122 ms
94,336 KB
testcase_48 AC 134 ms
98,688 KB
testcase_49 AC 177 ms
107,648 KB
testcase_50 AC 152 ms
102,656 KB
testcase_51 AC 146 ms
99,712 KB
testcase_52 AC 87 ms
79,232 KB
testcase_53 AC 91 ms
80,768 KB
testcase_54 AC 157 ms
106,240 KB
testcase_55 AC 100 ms
83,328 KB
testcase_56 AC 184 ms
114,688 KB
testcase_57 AC 160 ms
102,144 KB
testcase_58 AC 218 ms
120,704 KB
testcase_59 AC 205 ms
120,832 KB
testcase_60 AC 201 ms
120,704 KB
testcase_61 AC 179 ms
120,704 KB
testcase_62 AC 170 ms
120,704 KB
testcase_63 AC 40 ms
52,096 KB
testcase_64 AC 39 ms
52,096 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