結果

問題 No.1504 ヌメロニム
ユーザー そすうぽよそすうぽよ
提出日時 2020-12-12 07:31:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,101 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 204,160 KB
実行使用メモリ 12,496 KB
最終ジャッジ日時 2023-10-20 10:36:37
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
12,496 KB
testcase_01 AC 12 ms
12,380 KB
testcase_02 AC 13 ms
12,380 KB
testcase_03 AC 12 ms
12,380 KB
testcase_04 AC 12 ms
12,380 KB
testcase_05 AC 13 ms
12,380 KB
testcase_06 AC 13 ms
12,380 KB
testcase_07 AC 13 ms
12,380 KB
testcase_08 AC 13 ms
12,380 KB
testcase_09 AC 12 ms
12,380 KB
testcase_10 AC 13 ms
12,380 KB
testcase_11 AC 13 ms
12,380 KB
testcase_12 AC 13 ms
12,380 KB
testcase_13 AC 12 ms
12,380 KB
testcase_14 AC 12 ms
12,380 KB
testcase_15 AC 13 ms
12,380 KB
testcase_16 AC 13 ms
12,380 KB
testcase_17 AC 12 ms
12,380 KB
testcase_18 AC 13 ms
12,380 KB
testcase_19 AC 12 ms
12,380 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// kでループ、ペアを全探索
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
using vecll = vector<ll>;

constexpr ll MOD = 998244353;
constexpr ll MAX_F = 600000;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

int main() {
  vecll fact(MAX_F+1), finv(MAX_F+1);
  fact[0] = 1;
  REP(i,MAX_F) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  finv[MAX_F] = inv(fact[MAX_F], MOD);
  REP(ri,MAX_F) {
    int i = MAX_F - ri;
    finv[i-1] = finv[i] * i % MOD;
  }
  auto comb = [&] (ll n, ll k) {
    return fact[n] * finv[k] % MOD * finv[n-k] % MOD;
  };
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans = 0;
  REP(k,n-1) {
    ll tmp = 0;
    REP(i,n)REP(j,i) {
      if (s[j] != 'i' || s[i] != 'n') {
        continue;
      }
      ll span = i-j-1;
      if (span >= k) {
        tmp += comb(span, k);
        tmp %= MOD;
      }
    }
    ans ^= tmp;
  }
  cout<<ans<<"\n";
  return 0;
}
0