結果
問題 | No.1533 Don't be Negative! |
ユーザー | googol_S0 |
提出日時 | 2021-05-23 18:15:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 5,058 ms / 8,000 ms |
コード長 | 3,385 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 82,268 KB |
実行使用メモリ | 252,200 KB |
最終ジャッジ日時 | 2024-10-11 23:53:50 |
合計ジャッジ時間 | 226,534 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,287 ms
135,812 KB |
testcase_01 | AC | 4,364 ms
252,184 KB |
testcase_02 | AC | 4,909 ms
252,200 KB |
testcase_03 | AC | 4,987 ms
252,028 KB |
testcase_04 | AC | 2,467 ms
192,148 KB |
testcase_05 | AC | 4,349 ms
251,676 KB |
testcase_06 | AC | 4,365 ms
251,680 KB |
testcase_07 | AC | 2,477 ms
191,692 KB |
testcase_08 | AC | 2,451 ms
191,384 KB |
testcase_09 | AC | 4,904 ms
251,816 KB |
testcase_10 | AC | 4,367 ms
252,060 KB |
testcase_11 | AC | 4,925 ms
251,688 KB |
testcase_12 | AC | 2,473 ms
191,676 KB |
testcase_13 | AC | 1,295 ms
135,816 KB |
testcase_14 | AC | 1,290 ms
135,556 KB |
testcase_15 | AC | 2,460 ms
191,512 KB |
testcase_16 | AC | 4,380 ms
251,804 KB |
testcase_17 | AC | 1,303 ms
135,552 KB |
testcase_18 | AC | 4,445 ms
252,044 KB |
testcase_19 | AC | 4,351 ms
251,800 KB |
testcase_20 | AC | 2,471 ms
191,644 KB |
testcase_21 | AC | 4,362 ms
251,732 KB |
testcase_22 | AC | 2,452 ms
191,892 KB |
testcase_23 | AC | 1,287 ms
135,676 KB |
testcase_24 | AC | 2,463 ms
191,636 KB |
testcase_25 | AC | 5,058 ms
251,816 KB |
testcase_26 | AC | 4,906 ms
252,068 KB |
testcase_27 | AC | 2,458 ms
191,636 KB |
testcase_28 | AC | 4,361 ms
251,932 KB |
testcase_29 | AC | 4,388 ms
251,680 KB |
testcase_30 | AC | 4,966 ms
251,940 KB |
testcase_31 | AC | 4,372 ms
251,680 KB |
testcase_32 | AC | 4,393 ms
252,060 KB |
testcase_33 | AC | 4,951 ms
251,940 KB |
testcase_34 | AC | 2,451 ms
192,048 KB |
testcase_35 | AC | 1,295 ms
135,812 KB |
testcase_36 | AC | 4,909 ms
251,940 KB |
testcase_37 | AC | 4,928 ms
251,816 KB |
testcase_38 | AC | 4,899 ms
251,940 KB |
testcase_39 | AC | 4,361 ms
251,932 KB |
testcase_40 | AC | 4,360 ms
251,808 KB |
testcase_41 | AC | 4,357 ms
251,804 KB |
testcase_42 | AC | 4,909 ms
251,684 KB |
testcase_43 | AC | 4,359 ms
251,844 KB |
testcase_44 | AC | 4,336 ms
251,804 KB |
testcase_45 | AC | 4,396 ms
251,928 KB |
testcase_46 | AC | 4,400 ms
251,804 KB |
testcase_47 | AC | 4,969 ms
251,944 KB |
testcase_48 | AC | 4,410 ms
251,932 KB |
testcase_49 | AC | 4,403 ms
251,676 KB |
testcase_50 | AC | 4,956 ms
252,072 KB |
testcase_51 | AC | 4,920 ms
251,940 KB |
testcase_52 | AC | 4,937 ms
251,560 KB |
testcase_53 | AC | 4,926 ms
251,564 KB |
testcase_54 | AC | 4,985 ms
251,556 KB |
testcase_55 | AC | 4,931 ms
251,688 KB |
testcase_56 | AC | 4,902 ms
251,944 KB |
ソースコード
class FPS: sum_e=(911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497) sum_ie=(86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951) mod=998244353 g=3 def butterfly(self,a): n=len(a) h=(n-1).bit_length() for ph in range(1,h+1): w=1<<(ph-1) p=1<<(h-ph) now=1 for s in range(w): offset=s<<(h-ph+1) for i in range(p): l=a[i+offset] r=a[i+offset+p]*now r%=self.mod a[i+offset]=l+r a[i+offset]%=self.mod a[i+offset+p]=l-r a[i+offset+p]%=self.mod now*=self.sum_e[(~s & -~s).bit_length()-1] now%=self.mod def butterfly_inv(self,a): n=len(a) h=(n-1).bit_length() for ph in range(h,0,-1): w=1<<(ph-1) p=1<<(h-ph) inow=1 for s in range(w): offset=s<<(h-ph+1) for i in range(p): l=a[i+offset] r=a[i+offset+p] a[i+offset]=l+r a[i+offset]%=self.mod a[i+offset+p]=(l-r)*inow a[i+offset+p]%=self.mod inow*=self.sum_ie[(~s & -~s).bit_length()-1] inow%=self.mod def convolution(self,a,b): n=len(a);m=len(b) if not(a) or not(b): return [] if min(n,m)<=40: if n<m: n,m=m,n a,b=b,a res=[0]*(n+m-1) for i in range(n): for j in range(m): res[i+j]+=a[i]*b[j] res[i+j]%=self.mod return res z=1<<((n+m-2).bit_length()) a=a+[0]*(z-n) b=b+[0]*(z-m) self.butterfly(a) self.butterfly(b) c=[0]*z for i in range(z): c[i]=(a[i]*b[i])%self.mod self.butterfly_inv(c) iz=pow(z,self.mod-2,self.mod) for i in range(n+m-1): c[i]=(c[i]*iz)%self.mod return c[:n+m-1] lg2N=15 N,M,K=map(int,input().split()) mod=998244353 X=[0]*(lg2N+1) X[0]=[1]*(2*M+1) X[0][M+K]=0 X[0][M-K]=0 for i in range(lg2N): X[i+1]=FPS().convolution(X[i][:],X[i][:]) Y=[[[1] for i in range(1<<(lg2N+1-i))] for i in range(lg2N+1)] Y[-1][1]=X[-1][:] for i in range(lg2N-1,-1,-1): for j in range(len(Y[i+1])): Y[i][j<<1]=Y[i+1][j][:] Y[i][(j<<1)+1]=FPS().convolution(Y[i+1][j],X[i]) x=((1<<i)-1)*2*M+1 if len(Y[i][j<<1])>x: z=[Y[i][j<<1][(len(Y[i][j<<1])>>1)+k] for k in range(-(x>>1),(x>>1)+1)] Y[i][j<<1]=z if len(Y[i][(j<<1)+1])>x: z=[Y[i][(j<<1)+1][(len(Y[i][(j<<1)+1])>>1)+k] for k in range(-(x>>1),(x>>1)+1)] Y[i][(j<<1)+1]=z ANS=0 P=2*M-1 if K==0: P+=1 V=pow(P,N,mod) W=pow(P,mod-2,mod) U=1 for i in range(1,N+1): V=V*W%mod U=U*P%mod ANS+=(U-Y[0][i][0])*V*(N-i+1) print(ANS*pow(2,mod-2,mod)%mod)