Submission #785627

# Submission time Handle Problem Language Result Execution time Memory
785627 2023-07-17T10:53:50 Z devariaota Sprinkler (JOI22_sprinkler) C++17
0 / 100
4000 ms 25068 KB
#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;
                h[x] %= l; 
            }
            else
            {
                h[x] *= w;
                h[x] %= l;
                for(auto it:adj[x])
                {
                    h[it] *= w;
                    h[it] %= l;
                }
            }
        }
        else
        {
            cin>>x;
            cout<<h[x]<<'\n';
        }
    }
}

Compilation message

sprinkler.cpp: In function 'int main()':
sprinkler.cpp:28:17: warning: unused variable 'j' [-Wunused-variable]
   28 |     long long i,j;
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 169 ms 20620 KB Output is correct
3 Correct 262 ms 17868 KB Output is correct
4 Correct 197 ms 21924 KB Output is correct
5 Correct 188 ms 19532 KB Output is correct
6 Correct 200 ms 19520 KB Output is correct
7 Correct 202 ms 19816 KB Output is correct
8 Correct 169 ms 20300 KB Output is correct
9 Correct 228 ms 25068 KB Output is correct
10 Correct 258 ms 21540 KB Output is correct
11 Correct 175 ms 20820 KB Output is correct
12 Correct 228 ms 17556 KB Output is correct
13 Execution timed out 4048 ms 17664 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 169 ms 20620 KB Output is correct
3 Correct 262 ms 17868 KB Output is correct
4 Correct 197 ms 21924 KB Output is correct
5 Correct 188 ms 19532 KB Output is correct
6 Correct 200 ms 19520 KB Output is correct
7 Correct 202 ms 19816 KB Output is correct
8 Correct 169 ms 20300 KB Output is correct
9 Correct 228 ms 25068 KB Output is correct
10 Correct 258 ms 21540 KB Output is correct
11 Correct 175 ms 20820 KB Output is correct
12 Correct 228 ms 17556 KB Output is correct
13 Execution timed out 4048 ms 17664 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 185 ms 24120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -