結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー kaichou243kaichou243
提出日時 2023-06-17 00:03:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 205,168 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 23:09:37
合計ジャッジ時間 7,179 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 163 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 173 ms
4,380 KB
testcase_09 AC 182 ms
4,380 KB
testcase_10 AC 182 ms
4,376 KB
testcase_11 AC 182 ms
4,376 KB
testcase_12 AC 181 ms
4,376 KB
testcase_13 AC 182 ms
4,376 KB
testcase_14 AC 183 ms
4,376 KB
testcase_15 AC 92 ms
4,376 KB
testcase_16 AC 167 ms
4,376 KB
testcase_17 AC 173 ms
4,376 KB
testcase_18 AC 165 ms
4,376 KB
testcase_19 AC 91 ms
4,380 KB
testcase_20 AC 162 ms
4,384 KB
testcase_21 AC 132 ms
4,380 KB
testcase_22 AC 92 ms
4,376 KB
testcase_23 AC 66 ms
4,376 KB
testcase_24 AC 173 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 132 ms
4,380 KB
testcase_27 AC 172 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 126 ms
4,376 KB
testcase_31 AC 127 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
using ll=long long;
int main(){
	int n;
	cin>>n;
	mint ans=1;
	vector<int> u,f,w;
	ll su=0,sf=0,sw=0,cp=0;
	for(int i=0;i<n;i++){
		char s;
		int a;
		cin>>s>>a;
		if(s=='U') su+=a,u.push_back(a);
		else if(s=='F') sf+=a,f.push_back(a);
		else if(s=='W') sw+=a,w.push_back(a);
		else cp++,ans*=mint(n-1).pow(a);
	}
	mint tmp=0;
	for(auto& x:u) tmp+=mint(n-1).pow(su-x)*(mint(n-1).pow(x)-mint(n-2).pow(x));
	ans*=tmp;
	tmp=0;
	for(auto& x:f) tmp+=mint(n-1).pow(sf-x)*(mint(n-1).pow(x)-mint(n-2).pow(x));
	ans*=tmp;
	tmp=0;
	for(auto& x:w) tmp+=mint(n-1).pow(sw-x)*(mint(n-1).pow(x)-mint(n-2).pow(x));
	ans*=tmp;
	ans*=cp;
	cout<<ans.val()<<endl;
}
0