sycqwq @ 2020-11-15 10:47:34
rt
本地可以的
#include<bits/stdc++.h>
#define inf 2147283647
#define mod 998244353
using namespace std;
int n,m,a[1000006],qq;
struct node
{
vector<int> bh;
int id;
bool operator ==(const int &x){
return(this->id==x);
}
};
int bk[1000005];
vector<node> q;
vector<int> h;
int p[1000005],v[1000005],c[1000005];
int work(int x)
{
vector<node>::iterator it=find(q.begin(),q.end(),x);
for(int i=0;i<int(it->bh.size());i++)
{
if(p[it->bh[i]]||c[it->bh[i]])
h.push_back(int(it->bh[i]));
else
{
work(int(it->bh[i]));
}
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
bk[i]=1;
}
cin>>m;
for(int i=1;i<=m;i++)
{
int x;
cin>>x;
switch(x)
{
case 1:cin>>p[i]>>v[i];break;
case 2:cin>>c[i];break;
case 3:
{
int t;
cin>>t;
node tp;
tp.id=i;
tp.bh.clear();
for(int i=1;i<=t;i++)
{
int tt;
cin>>tt;
tp.bh.push_back(tt);
}
q.push_back(tp);
}
}
}
cin>>qq;
for(int i=1;i<=qq;i++)
{
int x;
cin>>x;
if(p[x]||c[x])
h.push_back(x);
else
{
work(x);
}
}
int q=1;
for(int i=0;i<int(h.size());i++)
{
// cout<<h[i]<<endl;
if(p[h[i]])
{
// cout<<bk[p[h[i]]]<<endl;
a[p[h[i]]]*=q/bk[p[h[i]]];
// cout<<1;
a[p[h[i]]]+=v[h[i]];
a[p[h[i]]]%=mod;
bk[p[h[i]]]=q%mod;
}
else
{
q*=c[h[i]];
q%=mod;
}
}
for(int i=1;i<=n;i++)
{
a[i]*=q/bk[i];
a[i]%=mod;
cout<<a[i]<<' ';
}
return 0;
}
by sipu6174 @ 2020-11-15 10:48:29
怀疑luogu日爆
by LiveZoom @ 2020-11-15 10:49:18
洛谷日爆
by ___new2zy___ @ 2020-11-15 10:49:18
评测姬裂开
by baiABC @ 2020-11-15 10:50:43
我连A+B Problem都编译失败
by 呵呵呵h @ 2020-11-15 10:51:38
一定是洛谷爆了