結果

問題 No.1504 ヌメロニム
ユーザー googol_S0googol_S0
提出日時 2021-05-07 22:55:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 4,512 ms
コンパイル使用メモリ 268,724 KB
実行使用メモリ 22,612 KB
最終ジャッジ日時 2023-10-13 14:15:01
合計ジャッジ時間 17,002 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
11,908 KB
testcase_01 AC 25 ms
11,980 KB
testcase_02 AC 28 ms
11,944 KB
testcase_03 AC 50 ms
11,924 KB
testcase_04 AC 30 ms
12,032 KB
testcase_05 AC 29 ms
11,868 KB
testcase_06 AC 26 ms
11,872 KB
testcase_07 AC 30 ms
11,948 KB
testcase_08 AC 26 ms
11,888 KB
testcase_09 AC 27 ms
12,092 KB
testcase_10 AC 26 ms
11,940 KB
testcase_11 AC 27 ms
12,084 KB
testcase_12 AC 28 ms
11,944 KB
testcase_13 AC 25 ms
11,892 KB
testcase_14 AC 25 ms
11,888 KB
testcase_15 AC 38 ms
11,964 KB
testcase_16 AC 58 ms
11,948 KB
testcase_17 AC 40 ms
11,924 KB
testcase_18 AC 47 ms
11,952 KB
testcase_19 AC 24 ms
12,008 KB
testcase_20 AC 55 ms
16,096 KB
testcase_21 AC 56 ms
15,888 KB
testcase_22 AC 55 ms
16,588 KB
testcase_23 AC 53 ms
15,964 KB
testcase_24 AC 436 ms
22,268 KB
testcase_25 AC 270 ms
22,080 KB
testcase_26 AC 457 ms
22,612 KB
testcase_27 AC 288 ms
22,064 KB
testcase_28 AC 278 ms
22,040 KB
testcase_29 AC 444 ms
22,528 KB
testcase_30 AC 462 ms
22,500 KB
testcase_31 AC 271 ms
21,908 KB
testcase_32 AC 288 ms
22,268 KB
testcase_33 AC 447 ms
22,452 KB
testcase_34 AC 93 ms
16,868 KB
testcase_35 AC 87 ms
16,824 KB
testcase_36 AC 246 ms
21,464 KB
testcase_37 AC 69 ms
16,712 KB
testcase_38 AC 444 ms
22,520 KB
testcase_39 AC 439 ms
22,576 KB
testcase_40 AC 437 ms
22,556 KB
testcase_41 AC 441 ms
22,560 KB
testcase_42 AC 442 ms
22,524 KB
testcase_43 AC 444 ms
22,564 KB
testcase_44 AC 437 ms
22,604 KB
testcase_45 AC 439 ms
22,600 KB
testcase_46 AC 439 ms
22,556 KB
testcase_47 AC 434 ms
22,524 KB
testcase_48 AC 274 ms
21,920 KB
testcase_49 AC 272 ms
21,820 KB
testcase_50 AC 59 ms
16,896 KB
testcase_51 AC 54 ms
16,180 KB
testcase_52 AC 42 ms
12,156 KB
testcase_53 AC 57 ms
16,028 KB
testcase_54 AC 36 ms
11,952 KB
testcase_55 AC 90 ms
16,796 KB
testcase_56 AC 63 ms
11,980 KB
testcase_57 AC 29 ms
11,940 KB
testcase_58 AC 54 ms
11,924 KB
testcase_59 AC 62 ms
11,924 KB
testcase_60 AC 58 ms
12,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=modint998244353;
const ll mod=998244353;
vector<mint> A(300000,0);
vector<mint> Y(300001,0);
vector<mint> g1(2,1);
vector<mint> g2(2,1);
vector<mint> inv(2,1);
int N;
void dfs(int l,int r){
  if(l+1>=r){
    return;
  }
  int x=(l+r)>>1;
  dfs(l,x);
  dfs(x,r);
  vector<mint> a(x-l);
  vector<mint> b(r-x);
  for(int i=l;i<x;i++){
    a[x-i-1]=(A[i].val())^1;
  }for(int i=x;i<r;i++){
    b[i-x]=A[i].val();
  }
  vector<mint> c=convolution(a,b);
  for(int i=0;i<(int)(c.size());i++){
    Y[i]+=c[i];
  }
  return;
}
int main(){
  cin>>N;
  string S;
  cin>>S;
  for(int i=0;i<N;i++){
    if(S[i]=='i'){
      A[i]=0;
    }else{
      A[i]=1;
    }
  }
  inv[0]=0;
  for(ll i=2;i<400003;i++){
    g1.push_back(g1[i-1]*i);
    inv.push_back(((-inv[mod%i])*(mod/i)));
    g2.push_back(g2[i-1]*inv[i]);
  }
  dfs(0,N);
  for(int i=0;i<=N;i++){
    Y[i]*=g1[i];
  }
  vector<mint> Z(N+1);
  for(int i=0;i<=N;i++){
    Z[N-i]=Y[i];
  }
  vector<mint> X=convolution(Z,g2);
  ll ANS=0;
  for(int i=0;i<=N;i++){
    ANS^=(X[i]*g2[N-i]).val();
  }
  cout<<ANS<<"\n";
}
0