結果
問題 | No.623 fudan no modulus to tigau |
ユーザー | WA_TLE |
提出日時 | 2017-12-23 00:14:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,109 bytes |
コンパイル時間 | 991 ms |
コンパイル使用メモリ | 113,768 KB |
最終ジャッジ日時 | 2025-01-05 06:14:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#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 llint 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; }