結果

問題 No.623 fudan no modulus to tigau
ユーザー WA_TLEWA_TLE
提出日時 2017-12-23 00:13:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 1,019 ms
コンパイル使用メモリ 117,120 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-22 21:34:52
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
#include<functional>
using namespace std;
typedef long long int llint;
typedef bool izryt;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int big=1e9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
const int mod=998244353;
//なにがNTTだ!
int main(void){
	int n;cin>>n;
	vector<tuple<int,int,int>>que(n-1);
	for(auto &it:que){cin>>get<0>(it)>>get<1>(it)>>get<2>(it);}
	int q;cin>>q;
	vector<llint>ans(n+1);
	while(q--){
		llint x;cin>>x;ans[0]=1;ans[1]=x;
		for(int i=0;i<n-1;i++){
			int t,a,b;tie(t,a,b)=que[i];
			if(t==1){ans[i+2]=ans[a]+ans[b];}
			if(t==2){ans[i+2]=a*ans[b];}
			if(t==3){ans[i+2]=ans[a]+ans[b];}
			ans[i+2]%=mod;
		}
		cout<<ans[n]<<endl;
	}
	return 0;
}
0