Submission #785634

#TimeUsernameProblemLanguageResultExecution timeMemory
785634andecaandeciSprinkler (JOI22_sprinkler)C++17
0 / 100
4094 ms18912 KiB
#include<bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC

long long n,l,tc,h[200069],level[200069],parent_node[200069],mul_par[200069];
vector<long long> adj[200069];

void dfs(long long x, long long p)
{
    for(auto j : adj[x])
    {
        if(j == p) continue;
        parent_node[j] = x;
        dfs(j,x);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long i,j;
    cin>>n>>l;
    for(i=1;i<n;i++)
    {
        long long u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(i=1;i<=n;i++)
    {
        mul_par[i] = 1ll;
        cin>>h[i];
        
    }
    parent_node[1] = 1ll;
    // dfs(1,-1);
    cin>>tc;
    while(tc--)
    {
        int typ;
        long long x,d,w;
        cin>>typ;
        if(typ == 1)
        {
            cin>>x>>d>>w;
            if(d == 0)
            {
                h[x] *= w;
                if(h[x] >= l) {
                h[x] %= l; 
                }
            }
            else
            {
                h[x] *= w;
                if(h[x] >= l) {
                h[x] %= l; 
                }
                for(auto it:adj[x])
                {
                    h[it] *= w;
                    if(h[it] >= l) {
                    h[it] %= l; 
                    }
                }
            }
        }
        else
        {
            cin>>x;
            cout<<h[x]<<'\n';
        }
    }
}

Compilation message (stderr)

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:28:17: warning: unused variable 'j' [-Wunused-variable]
   28 |     long long i,j;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...