mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-08-21 18:52:07 +00:00
update
This commit is contained in:
parent
2f6d4e78c9
commit
4bf80bde68
56
src/8/16/P7077.cpp
Normal file
56
src/8/16/P7077.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
using ll = int64_t;
|
||||
|
||||
const ll maxn{ll(1e5+5)}, mod{998244353};
|
||||
ll n,a[maxn],m,t[maxn],p[maxn],v[maxn],q;
|
||||
vector<ll> e[maxn];
|
||||
|
||||
void dfs(ll const &f){
|
||||
if(t[f]==1){
|
||||
a[p[f]]=(a[p[f]]+v[f])%mod;
|
||||
}else if(t[f]==2){
|
||||
for(ll j{1};j<=n;j++){
|
||||
a[j]=(a[j]*v[f])%mod;
|
||||
}
|
||||
}else{
|
||||
for(auto const&i:e[f]){
|
||||
dfs(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
|
||||
cin>>n;
|
||||
for(ll i{1};i<=n;i++){
|
||||
cin>>a[i];
|
||||
}
|
||||
cin>>m;
|
||||
for(ll i{1};i<=m;i++){
|
||||
cin>>t[i];
|
||||
if(t[i]==1){
|
||||
cin>>p[i]>>v[i];
|
||||
}else if(t[i]==2){
|
||||
cin>>v[i];
|
||||
}else{
|
||||
ll c;
|
||||
cin>>c;
|
||||
while(c--){
|
||||
ll f;
|
||||
cin>>f;
|
||||
e[i].emplace_back(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
cin>>q;
|
||||
for(ll i{1};i<=q;i++){
|
||||
ll f;
|
||||
cin>>f;
|
||||
dfs(f);
|
||||
}
|
||||
for(ll i{1};i<=n;i++){
|
||||
cout<<a[i]<<' ';
|
||||
}
|
||||
cout<<'\n';
|
||||
}
|
Loading…
Reference in New Issue
Block a user