結果

問題 No.1533 Don't be Negative!
ユーザー googol_S0googol_S0
提出日時 2021-05-23 18:12:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,484 bytes
コンパイル時間 5,222 ms
コンパイル使用メモリ 268,520 KB
実行使用メモリ 45,576 KB
最終ジャッジ日時 2024-04-20 03:39:53
合計ジャッジ時間 33,318 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,872 KB
testcase_01 AC 308 ms
39,520 KB
testcase_02 AC 340 ms
45,448 KB
testcase_03 AC 342 ms
45,452 KB
testcase_04 AC 160 ms
25,988 KB
testcase_05 AC 310 ms
39,648 KB
testcase_06 AC 315 ms
39,524 KB
testcase_07 AC 166 ms
25,904 KB
testcase_08 AC 157 ms
25,860 KB
testcase_09 AC 337 ms
45,452 KB
testcase_10 AC 309 ms
39,524 KB
testcase_11 AC 331 ms
45,448 KB
testcase_12 AC 166 ms
25,988 KB
testcase_13 AC 78 ms
15,872 KB
testcase_14 AC 82 ms
15,744 KB
testcase_15 AC 169 ms
25,796 KB
testcase_16 AC 297 ms
39,776 KB
testcase_17 AC 82 ms
15,744 KB
testcase_18 AC 309 ms
39,520 KB
testcase_19 AC 302 ms
39,516 KB
testcase_20 RE -
testcase_21 AC 308 ms
39,520 KB
testcase_22 AC 168 ms
25,860 KB
testcase_23 RE -
testcase_24 AC 169 ms
26,116 KB
testcase_25 AC 342 ms
45,320 KB
testcase_26 AC 337 ms
45,452 KB
testcase_27 AC 165 ms
25,860 KB
testcase_28 AC 311 ms
39,536 KB
testcase_29 AC 306 ms
39,776 KB
testcase_30 RE -
testcase_31 AC 304 ms
39,520 KB
testcase_32 AC 308 ms
39,652 KB
testcase_33 AC 342 ms
45,344 KB
testcase_34 AC 164 ms
25,856 KB
testcase_35 RE -
testcase_36 AC 344 ms
45,324 KB
testcase_37 AC 336 ms
45,320 KB
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 312 ms
39,520 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,452 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