結果

問題 No.1533 Don't be Negative!
ユーザー googol_S0googol_S0
提出日時 2021-05-23 18:12:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,484 bytes
コンパイル時間 5,806 ms
コンパイル使用メモリ 274,492 KB
実行使用メモリ 45,732 KB
最終ジャッジ日時 2023-08-02 03:21:47
合計ジャッジ時間 36,255 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,856 KB
testcase_01 AC 314 ms
39,444 KB
testcase_02 AC 338 ms
45,200 KB
testcase_03 AC 332 ms
45,188 KB
testcase_04 AC 161 ms
25,740 KB
testcase_05 AC 302 ms
39,380 KB
testcase_06 AC 304 ms
39,392 KB
testcase_07 AC 158 ms
25,728 KB
testcase_08 AC 162 ms
25,664 KB
testcase_09 AC 335 ms
45,192 KB
testcase_10 AC 316 ms
39,508 KB
testcase_11 AC 343 ms
45,196 KB
testcase_12 AC 166 ms
25,612 KB
testcase_13 AC 79 ms
16,000 KB
testcase_14 AC 81 ms
15,724 KB
testcase_15 AC 164 ms
25,668 KB
testcase_16 AC 310 ms
39,460 KB
testcase_17 AC 79 ms
15,932 KB
testcase_18 AC 308 ms
39,336 KB
testcase_19 AC 310 ms
39,388 KB
testcase_20 RE -
testcase_21 AC 315 ms
39,440 KB
testcase_22 AC 169 ms
25,740 KB
testcase_23 RE -
testcase_24 AC 173 ms
25,720 KB
testcase_25 AC 362 ms
45,268 KB
testcase_26 AC 345 ms
45,264 KB
testcase_27 AC 169 ms
25,600 KB
testcase_28 AC 314 ms
39,332 KB
testcase_29 AC 307 ms
39,460 KB
testcase_30 RE -
testcase_31 AC 307 ms
39,576 KB
testcase_32 AC 316 ms
39,504 KB
testcase_33 AC 345 ms
45,352 KB
testcase_34 AC 163 ms
25,680 KB
testcase_35 RE -
testcase_36 AC 343 ms
45,268 KB
testcase_37 AC 339 ms
45,200 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 314 ms
39,496 KB
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 AC 341 ms
45,396 KB
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
using mint=modint998244353;
const int log2NMAX=14;
int main(){
  int N,M,K;
  cin>>N>>M>>K;
  vector<vector<mint>> X(log2NMAX+1,vector<mint>(0));
  vector<vector<vector<mint>>> Y(log2NMAX+1,vector<vector<mint>>(0));
  X[0].assign(2*M+1,1);
  X[0][M-K]=0;
  X[0][M+K]=0;
  for(int i=0;i<log2NMAX;i++){
    X[i+1]=convolution(X[i],X[i]);
  }for(int i=0;i<log2NMAX+1;i++){
    Y[i].assign(1<<(log2NMAX+1-i),vector<mint>(1,1));
  }
  Y[log2NMAX][1]=X[log2NMAX];
  vector<int> t(log2NMAX+3,0);
  t[1]=1;
  for(int i=2;i<log2NMAX+3;i++){
    t[i]=t[i-1]*2;
  }
  for(int i=log2NMAX-1;i>=0;i--){
    for(int j=0;j<(int)(Y[i+1].size());j++){
      Y[i][j<<1]=Y[i+1][j];
      Y[i][(j<<1)+1]=convolution(Y[i+1][j],X[i]);
      vector<mint> Z((t[i+1]-1)*2*M+1);
      if(Y[i][j<<1].size()>=Z.size()){
        for(int k=0;k<(int)(Z.size());k++){
          Z[k]=Y[i][j<<1][(Y[i][j<<1].size()>>1)+k-(Z.size()>>1)];
        }
        Y[i][j<<1]=Z;
      }if(Y[i][(j<<1)+1].size()>=Z.size()){
        for(int k=0;k<(int)(Z.size());k++){
          Z[k]=Y[i][(j<<1)+1][(Y[i][(j<<1)+1].size()>>1)+k-(Z.size()>>1)];
        }
        Y[i][(j<<1)+1]=Z;
      }
    }
  }
  mint ANS=0;
  mint P=2*M-1;
  if(K==0){
    P+=1;
  }
  mint V=P.pow(N);
  mint W=P.inv();
  mint U=1;
  for(int i=1;i<=N;i++){
    V*=W;
    U*=P;
    ANS+=(U-Y[0][i][0])*V*(N-i+1);
  }
  cout<<(ANS/2).val()<<"\n";
}
0