結果

問題 No.1013 〇マス進む
ユーザー takakintakakin
提出日時 2020-03-23 00:07:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 145,244 KB
最終ジャッジ日時 2023-08-27 01:15:33
合計ジャッジ時間 19,279 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,368 KB
testcase_01 AC 75 ms
70,988 KB
testcase_02 AC 75 ms
71,108 KB
testcase_03 AC 82 ms
75,512 KB
testcase_04 AC 80 ms
75,620 KB
testcase_05 AC 82 ms
75,640 KB
testcase_06 AC 83 ms
75,660 KB
testcase_07 AC 85 ms
75,768 KB
testcase_08 AC 82 ms
75,792 KB
testcase_09 AC 84 ms
76,396 KB
testcase_10 AC 83 ms
75,844 KB
testcase_11 AC 81 ms
75,912 KB
testcase_12 AC 84 ms
76,264 KB
testcase_13 AC 100 ms
77,332 KB
testcase_14 AC 159 ms
108,440 KB
testcase_15 AC 208 ms
128,720 KB
testcase_16 AC 198 ms
125,152 KB
testcase_17 AC 157 ms
104,832 KB
testcase_18 AC 164 ms
111,828 KB
testcase_19 AC 136 ms
96,512 KB
testcase_20 AC 226 ms
142,020 KB
testcase_21 AC 144 ms
102,224 KB
testcase_22 AC 167 ms
112,884 KB
testcase_23 AC 117 ms
87,068 KB
testcase_24 AC 238 ms
143,880 KB
testcase_25 AC 225 ms
142,892 KB
testcase_26 AC 117 ms
87,036 KB
testcase_27 AC 141 ms
100,956 KB
testcase_28 AC 118 ms
86,832 KB
testcase_29 AC 220 ms
141,188 KB
testcase_30 AC 142 ms
97,968 KB
testcase_31 AC 178 ms
118,780 KB
testcase_32 AC 153 ms
107,772 KB
testcase_33 AC 157 ms
107,752 KB
testcase_34 AC 206 ms
127,320 KB
testcase_35 AC 200 ms
123,996 KB
testcase_36 AC 100 ms
77,236 KB
testcase_37 AC 100 ms
77,196 KB
testcase_38 AC 214 ms
131,460 KB
testcase_39 AC 134 ms
93,528 KB
testcase_40 AC 206 ms
127,076 KB
testcase_41 AC 119 ms
87,784 KB
testcase_42 AC 156 ms
106,228 KB
testcase_43 AC 134 ms
94,680 KB
testcase_44 AC 161 ms
107,916 KB
testcase_45 AC 150 ms
104,228 KB
testcase_46 AC 122 ms
88,492 KB
testcase_47 AC 153 ms
105,984 KB
testcase_48 AC 167 ms
111,892 KB
testcase_49 AC 200 ms
125,572 KB
testcase_50 AC 182 ms
118,816 KB
testcase_51 AC 176 ms
114,456 KB
testcase_52 AC 111 ms
82,976 KB
testcase_53 AC 117 ms
85,444 KB
testcase_54 AC 192 ms
123,676 KB
testcase_55 AC 126 ms
89,348 KB
testcase_56 AC 229 ms
135,904 KB
testcase_57 AC 192 ms
117,420 KB
testcase_58 AC 254 ms
145,148 KB
testcase_59 AC 270 ms
145,080 KB
testcase_60 AC 247 ms
145,244 KB
testcase_61 AC 247 ms
143,484 KB
testcase_62 AC 225 ms
143,708 KB
testcase_63 AC 74 ms
71,188 KB
testcase_64 AC 73 ms
71,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
P=[int(i) for i in input().split()]
A=[[0]*n for i in range(31)]
B=[[0]*n for i in range(31)]
A[0]=P
for i in range(n):
  A[1][i]=(A[0][i]+i+1)%n
  if A[0][i]+i+1>n:
    B[1][i]=1
  if A[1][i]==0:
    A[1][i]=n
for i in range(1,30):
  for j in range(n):
    A[i+1][j]=A[i][A[i][j]-1]
    B[i+1][j]=B[i][j]+B[i][A[i][j]-1]
Ans1=[int(i)+1 for i in range(n)]
Ans2=[0]*n
for i in range(30):
  if k&(1<<i):
    for j in range(n):
      Ans2[j]+=B[i+1][Ans1[j]-1]
      Ans1[j]=A[i+1][Ans1[j]-1]
      
Ans=[]
for i in range(n):
  Ans.append(Ans1[i]+Ans2[i]*n)
print(*Ans,sep="\n")
0