結果

問題 No.1504 ヌメロニム
ユーザー chocoruskchocorusk
提出日時 2021-05-07 23:05:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 1,412 bytes
コンパイル時間 3,702 ms
コンパイル使用メモリ 195,788 KB
実行使用メモリ 38,392 KB
最終ジャッジ日時 2023-10-13 14:24:55
合計ジャッジ時間 9,425 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,132 KB
testcase_01 AC 8 ms
19,104 KB
testcase_02 AC 7 ms
19,272 KB
testcase_03 AC 7 ms
19,112 KB
testcase_04 AC 7 ms
19,168 KB
testcase_05 AC 7 ms
19,064 KB
testcase_06 AC 7 ms
18,996 KB
testcase_07 AC 7 ms
19,184 KB
testcase_08 AC 8 ms
19,044 KB
testcase_09 AC 7 ms
19,100 KB
testcase_10 AC 7 ms
19,280 KB
testcase_11 AC 8 ms
19,052 KB
testcase_12 AC 8 ms
19,052 KB
testcase_13 AC 7 ms
19,052 KB
testcase_14 AC 7 ms
19,056 KB
testcase_15 AC 7 ms
19,160 KB
testcase_16 AC 7 ms
19,060 KB
testcase_17 AC 7 ms
19,056 KB
testcase_18 AC 8 ms
19,108 KB
testcase_19 AC 7 ms
19,292 KB
testcase_20 AC 8 ms
19,228 KB
testcase_21 AC 8 ms
19,128 KB
testcase_22 AC 9 ms
19,208 KB
testcase_23 AC 8 ms
19,060 KB
testcase_24 AC 169 ms
38,012 KB
testcase_25 AC 92 ms
30,108 KB
testcase_26 AC 170 ms
38,244 KB
testcase_27 AC 96 ms
30,996 KB
testcase_28 AC 96 ms
31,236 KB
testcase_29 AC 167 ms
38,236 KB
testcase_30 AC 166 ms
38,188 KB
testcase_31 AC 92 ms
30,452 KB
testcase_32 AC 93 ms
30,860 KB
testcase_33 AC 166 ms
37,888 KB
testcase_34 AC 28 ms
21,736 KB
testcase_35 AC 26 ms
21,312 KB
testcase_36 AC 88 ms
28,360 KB
testcase_37 AC 17 ms
20,132 KB
testcase_38 AC 171 ms
38,384 KB
testcase_39 AC 172 ms
38,356 KB
testcase_40 AC 167 ms
38,292 KB
testcase_41 AC 170 ms
38,308 KB
testcase_42 AC 167 ms
38,284 KB
testcase_43 AC 167 ms
38,228 KB
testcase_44 AC 169 ms
38,344 KB
testcase_45 AC 168 ms
38,392 KB
testcase_46 AC 172 ms
38,308 KB
testcase_47 AC 170 ms
38,388 KB
testcase_48 AC 93 ms
30,464 KB
testcase_49 AC 92 ms
30,096 KB
testcase_50 AC 9 ms
19,268 KB
testcase_51 AC 8 ms
19,120 KB
testcase_52 AC 8 ms
19,008 KB
testcase_53 AC 8 ms
19,144 KB
testcase_54 AC 8 ms
19,064 KB
testcase_55 AC 26 ms
21,424 KB
testcase_56 AC 8 ms
19,000 KB
testcase_57 AC 7 ms
19,272 KB
testcase_58 AC 7 ms
19,116 KB
testcase_59 AC 7 ms
19,004 KB
testcase_60 AC 7 ms
19,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
	int n; cin>>n;
	string s; cin>>s;
	vector<mint> a(n), b(n);
	for(int i=0; i<n; i++){
		if(s[i]=='i') a[i]=1;
	}
	for(int i=0; i<n; i++){
		if(s[i]=='n') b[n-1-i]=1;
	}
	auto c=convolution(a, b);
	fac(n);
	vector<mint> d(n-1);
	for(int i=0; i<n-1; i++) d[i]=c[n-2-i]*f[i];
	vector<mint> e(n-1);
	for(int i=0; i<n-1; i++) e[i]=invf[n-2-i];
	auto c1=convolution(d, e);
	int ans=0;
	for(int i=0; i<n-1; i++){
		mint ans1=c1[n-2+i]*invf[i];
		ans^=ans1.val();
	}
	cout<<ans<<endl;
    return 0;
}
0