結果
問題 | No.1013 〇マス進む |
ユーザー | vwxyz |
提出日時 | 2023-03-31 10:55:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 916 ms / 2,000 ms |
コード長 | 1,725 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 81,884 KB |
実行使用メモリ | 256,564 KB |
最終ジャッジ日時 | 2024-09-22 16:10:21 |
合計ジャッジ時間 | 20,775 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,676 KB |
testcase_01 | AC | 38 ms
53,488 KB |
testcase_02 | AC | 38 ms
53,072 KB |
testcase_03 | AC | 52 ms
64,924 KB |
testcase_04 | AC | 45 ms
61,564 KB |
testcase_05 | AC | 52 ms
64,112 KB |
testcase_06 | AC | 52 ms
63,640 KB |
testcase_07 | AC | 54 ms
66,344 KB |
testcase_08 | AC | 52 ms
64,696 KB |
testcase_09 | AC | 55 ms
65,324 KB |
testcase_10 | AC | 54 ms
65,732 KB |
testcase_11 | AC | 52 ms
64,300 KB |
testcase_12 | AC | 55 ms
65,932 KB |
testcase_13 | AC | 80 ms
78,676 KB |
testcase_14 | AC | 209 ms
104,124 KB |
testcase_15 | AC | 341 ms
107,548 KB |
testcase_16 | AC | 349 ms
124,436 KB |
testcase_17 | AC | 181 ms
94,148 KB |
testcase_18 | AC | 239 ms
106,880 KB |
testcase_19 | AC | 140 ms
89,520 KB |
testcase_20 | AC | 390 ms
117,936 KB |
testcase_21 | AC | 173 ms
98,416 KB |
testcase_22 | AC | 226 ms
97,732 KB |
testcase_23 | AC | 102 ms
82,156 KB |
testcase_24 | AC | 452 ms
148,100 KB |
testcase_25 | AC | 391 ms
118,496 KB |
testcase_26 | AC | 111 ms
86,532 KB |
testcase_27 | AC | 149 ms
92,448 KB |
testcase_28 | AC | 103 ms
82,136 KB |
testcase_29 | AC | 371 ms
116,556 KB |
testcase_30 | AC | 156 ms
95,572 KB |
testcase_31 | AC | 284 ms
116,184 KB |
testcase_32 | AC | 187 ms
102,072 KB |
testcase_33 | AC | 315 ms
148,128 KB |
testcase_34 | AC | 537 ms
203,284 KB |
testcase_35 | AC | 594 ms
194,888 KB |
testcase_36 | AC | 94 ms
80,488 KB |
testcase_37 | AC | 94 ms
80,640 KB |
testcase_38 | AC | 658 ms
217,832 KB |
testcase_39 | AC | 212 ms
110,396 KB |
testcase_40 | AC | 674 ms
202,440 KB |
testcase_41 | AC | 156 ms
94,164 KB |
testcase_42 | AC | 314 ms
144,248 KB |
testcase_43 | AC | 198 ms
97,752 KB |
testcase_44 | AC | 342 ms
149,120 KB |
testcase_45 | AC | 278 ms
137,128 KB |
testcase_46 | AC | 153 ms
96,624 KB |
testcase_47 | AC | 268 ms
119,564 KB |
testcase_48 | AC | 354 ms
159,792 KB |
testcase_49 | AC | 621 ms
201,760 KB |
testcase_50 | AC | 482 ms
180,028 KB |
testcase_51 | AC | 415 ms
166,740 KB |
testcase_52 | AC | 117 ms
89,088 KB |
testcase_53 | AC | 143 ms
92,672 KB |
testcase_54 | AC | 459 ms
194,048 KB |
testcase_55 | AC | 172 ms
98,404 KB |
testcase_56 | AC | 697 ms
230,876 KB |
testcase_57 | AC | 537 ms
174,668 KB |
testcase_58 | AC | 916 ms
256,564 KB |
testcase_59 | AC | 841 ms
256,380 KB |
testcase_60 | AC | 744 ms
256,244 KB |
testcase_61 | AC | 375 ms
120,852 KB |
testcase_62 | AC | 131 ms
99,180 KB |
testcase_63 | AC | 40 ms
52,652 KB |
testcase_64 | AC | 41 ms
52,608 KB |
ソースコード
import sys readline=sys.stdin.readline class Path_Doubling: def __init__(self,N,permutation,lst=None,f=None,e=None): self.N=N self.permutation=permutation self.lst=lst self.f=f self.e=e def Build_Next(self,K): self.K=K self.k=self.K.bit_length() self.permutation_doubling=[[self.permutation[n]] for n in range(self.N)] self.doubling=[[self.lst[n]] for n in range(self.N)] for k in range(1,self.k): for n in range(self.N): self.permutation_doubling[n].append(self.permutation_doubling[self.permutation_doubling[n][k-1]][k-1]) self.doubling[n].append(self.f(self.doubling[n][k-1],self.doubling[self.permutation_doubling[n][k-1]][k-1])) def Permutation_Doubling(self,N,K): for k in range(self.k): if K>>k&1: N=self.permutation_doubling[N][k] return N def Doubling(self,N,K): retu=self.e for k in range(self.k): if K>>k&1: retu=self.f(retu,self.doubling[N][k]) N=self.permutation_doubling[N][k] return N,retu def Bisect(self,x,is_ok): if not is_ok(x): return -1,None K=0 for k in range(self.k-1,-1,-1): if K|1<<k<=self.K and is_ok(self.permutation_doubling[x][k]): K|=1<<k x=self.permutation_doubling[x][k] return K,x N,K=map(int,readline().split()) P=list(map(int,readline().split())) PD=Path_Doubling(N,[(P[i]+i)%N for i in range(N)],[(i+P[i])//N for i in range(N)],lambda x,y:x+y,0) PD.Build_Next(K) for i in range(N): pd,d=PD.Doubling(i,K) ans=pd+d*N+1 print(ans)