結果
問題 | No.1013 〇マス進む |
ユーザー | vwxyz |
提出日時 | 2023-03-31 10:55:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,136 ms / 2,000 ms |
コード長 | 1,760 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 82,704 KB |
実行使用メモリ | 256,504 KB |
最終ジャッジ日時 | 2024-09-22 16:09:58 |
合計ジャッジ時間 | 24,129 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,696 KB |
testcase_01 | AC | 38 ms
53,832 KB |
testcase_02 | AC | 39 ms
53,484 KB |
testcase_03 | AC | 55 ms
64,708 KB |
testcase_04 | AC | 49 ms
62,196 KB |
testcase_05 | AC | 56 ms
66,292 KB |
testcase_06 | AC | 53 ms
63,660 KB |
testcase_07 | AC | 59 ms
67,912 KB |
testcase_08 | AC | 54 ms
64,908 KB |
testcase_09 | AC | 59 ms
67,504 KB |
testcase_10 | AC | 59 ms
66,900 KB |
testcase_11 | AC | 56 ms
66,524 KB |
testcase_12 | AC | 61 ms
67,456 KB |
testcase_13 | AC | 86 ms
78,812 KB |
testcase_14 | AC | 243 ms
104,368 KB |
testcase_15 | AC | 381 ms
107,420 KB |
testcase_16 | AC | 418 ms
124,696 KB |
testcase_17 | AC | 201 ms
94,284 KB |
testcase_18 | AC | 283 ms
106,764 KB |
testcase_19 | AC | 170 ms
89,784 KB |
testcase_20 | AC | 479 ms
118,076 KB |
testcase_21 | AC | 201 ms
98,216 KB |
testcase_22 | AC | 277 ms
97,840 KB |
testcase_23 | AC | 119 ms
81,892 KB |
testcase_24 | AC | 572 ms
148,028 KB |
testcase_25 | AC | 523 ms
118,592 KB |
testcase_26 | AC | 122 ms
86,232 KB |
testcase_27 | AC | 171 ms
92,272 KB |
testcase_28 | AC | 120 ms
82,448 KB |
testcase_29 | AC | 470 ms
116,648 KB |
testcase_30 | AC | 187 ms
95,496 KB |
testcase_31 | AC | 344 ms
115,944 KB |
testcase_32 | AC | 227 ms
102,116 KB |
testcase_33 | AC | 377 ms
147,920 KB |
testcase_34 | AC | 680 ms
203,152 KB |
testcase_35 | AC | 668 ms
194,964 KB |
testcase_36 | AC | 100 ms
80,492 KB |
testcase_37 | AC | 100 ms
80,276 KB |
testcase_38 | AC | 763 ms
218,092 KB |
testcase_39 | AC | 234 ms
110,548 KB |
testcase_40 | AC | 777 ms
202,768 KB |
testcase_41 | AC | 171 ms
94,288 KB |
testcase_42 | AC | 362 ms
144,036 KB |
testcase_43 | AC | 215 ms
97,404 KB |
testcase_44 | AC | 382 ms
148,940 KB |
testcase_45 | AC | 319 ms
137,144 KB |
testcase_46 | AC | 191 ms
96,612 KB |
testcase_47 | AC | 325 ms
119,844 KB |
testcase_48 | AC | 502 ms
160,184 KB |
testcase_49 | AC | 721 ms
202,008 KB |
testcase_50 | AC | 554 ms
179,792 KB |
testcase_51 | AC | 464 ms
166,912 KB |
testcase_52 | AC | 131 ms
88,896 KB |
testcase_53 | AC | 155 ms
92,664 KB |
testcase_54 | AC | 509 ms
194,200 KB |
testcase_55 | AC | 193 ms
98,488 KB |
testcase_56 | AC | 795 ms
230,564 KB |
testcase_57 | AC | 606 ms
174,652 KB |
testcase_58 | AC | 1,136 ms
256,316 KB |
testcase_59 | AC | 995 ms
256,504 KB |
testcase_60 | AC | 811 ms
256,312 KB |
testcase_61 | AC | 426 ms
121,128 KB |
testcase_62 | AC | 147 ms
99,292 KB |
testcase_63 | AC | 37 ms
53,264 KB |
testcase_64 | AC | 40 ms
52,836 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=PD.Permutation_Doubling(i,K) _,d=PD.Doubling(i,K) ans=pd+d*N+1 print(ans)