結果
問題 | No.1013 〇マス進む |
ユーザー | vwxyz |
提出日時 | 2023-03-31 10:52:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,142 ms / 2,000 ms |
コード長 | 2,378 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 82,412 KB |
実行使用メモリ | 256,624 KB |
最終ジャッジ日時 | 2024-09-22 16:07:23 |
合計ジャッジ時間 | 24,618 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,332 KB |
testcase_01 | AC | 39 ms
52,748 KB |
testcase_02 | AC | 39 ms
53,604 KB |
testcase_03 | AC | 58 ms
66,452 KB |
testcase_04 | AC | 51 ms
63,096 KB |
testcase_05 | AC | 59 ms
66,848 KB |
testcase_06 | AC | 56 ms
65,840 KB |
testcase_07 | AC | 62 ms
67,768 KB |
testcase_08 | AC | 57 ms
67,108 KB |
testcase_09 | AC | 62 ms
67,660 KB |
testcase_10 | AC | 63 ms
67,524 KB |
testcase_11 | AC | 60 ms
66,912 KB |
testcase_12 | AC | 63 ms
67,748 KB |
testcase_13 | AC | 90 ms
78,568 KB |
testcase_14 | AC | 252 ms
104,016 KB |
testcase_15 | AC | 406 ms
107,808 KB |
testcase_16 | AC | 426 ms
124,712 KB |
testcase_17 | AC | 221 ms
94,112 KB |
testcase_18 | AC | 295 ms
107,180 KB |
testcase_19 | AC | 164 ms
89,916 KB |
testcase_20 | AC | 491 ms
118,456 KB |
testcase_21 | AC | 206 ms
98,288 KB |
testcase_22 | AC | 276 ms
97,872 KB |
testcase_23 | AC | 119 ms
82,224 KB |
testcase_24 | AC | 601 ms
147,756 KB |
testcase_25 | AC | 512 ms
119,328 KB |
testcase_26 | AC | 125 ms
86,164 KB |
testcase_27 | AC | 173 ms
92,496 KB |
testcase_28 | AC | 124 ms
82,408 KB |
testcase_29 | AC | 479 ms
117,044 KB |
testcase_30 | AC | 191 ms
95,400 KB |
testcase_31 | AC | 343 ms
116,856 KB |
testcase_32 | AC | 229 ms
102,316 KB |
testcase_33 | AC | 381 ms
147,704 KB |
testcase_34 | AC | 679 ms
203,164 KB |
testcase_35 | AC | 690 ms
195,112 KB |
testcase_36 | AC | 102 ms
80,480 KB |
testcase_37 | AC | 99 ms
80,368 KB |
testcase_38 | AC | 744 ms
218,532 KB |
testcase_39 | AC | 244 ms
110,976 KB |
testcase_40 | AC | 807 ms
202,648 KB |
testcase_41 | AC | 173 ms
94,116 KB |
testcase_42 | AC | 384 ms
144,128 KB |
testcase_43 | AC | 223 ms
97,664 KB |
testcase_44 | AC | 399 ms
148,992 KB |
testcase_45 | AC | 343 ms
137,088 KB |
testcase_46 | AC | 193 ms
96,896 KB |
testcase_47 | AC | 332 ms
119,380 KB |
testcase_48 | AC | 441 ms
160,496 KB |
testcase_49 | AC | 729 ms
201,824 KB |
testcase_50 | AC | 569 ms
180,016 KB |
testcase_51 | AC | 487 ms
167,276 KB |
testcase_52 | AC | 134 ms
88,960 KB |
testcase_53 | AC | 163 ms
92,800 KB |
testcase_54 | AC | 546 ms
194,328 KB |
testcase_55 | AC | 207 ms
98,176 KB |
testcase_56 | AC | 836 ms
230,884 KB |
testcase_57 | AC | 640 ms
175,204 KB |
testcase_58 | AC | 1,142 ms
256,552 KB |
testcase_59 | AC | 1,008 ms
256,364 KB |
testcase_60 | AC | 830 ms
256,624 KB |
testcase_61 | AC | 453 ms
121,504 KB |
testcase_62 | AC | 148 ms
98,944 KB |
testcase_63 | AC | 38 ms
52,352 KB |
testcase_64 | AC | 39 ms
52,480 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=None): if K==None: self.K=self.N else: self.K=K self.k=self.K.bit_length() self.permutation_doubling=[[self.permutation[n]] for n in range(self.N)] if self.lst!=None: self.doubling=[[self.lst[n]] for n in range(self.N)] for k in range(1,self.k): for n in range(self.N): if self.permutation_doubling[n][k-1]==None: self.permutation_doubling[n].append(None) if self.f!=None: self.doubling[n].append(None) if self.permutation_doubling[n][k-1]!=None: self.permutation_doubling[n].append(self.permutation_doubling[self.permutation_doubling[n][k-1]][k-1]) if self.f!=None: 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): if K<0 or 1<<self.k<=K: return None for k in range(self.k): if K>>k&1 and N!=None: N=self.permutation_doubling[N][k] return N def Doubling(self,N,K): if K<0: return self.e retu=self.e for k in range(self.k): if K>>k&1: if self.permutation_doubling[N][k]==None: return None retu=self.f(retu,self.doubling[N][k]) N=self.permutation_doubling[N][k] return 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)