Submission #998418

# Submission time Handle Problem Language Result Execution time Memory
998418 2024-06-14T00:37:05 Z efishel Sprinkler (JOI22_sprinkler) C++17
0 / 100
4000 ms 23636 KB
//Logan/Sprinkler
#include<bits/stdc++.h>
using namespace std;

#define nl '\n'

int N,L,Q,t,a,b,h[200005];
vector<int>ad[200005];

void dfs(int u,int p,int d,int w){
    h[u]=(h[u]*w)%L;
    if(0<d)for(auto v:ad[u])if(v!=p){
        dfs(v,u,d-1,w);
    }
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cin>>N>>L;
    for(int i=1;i<N;i++){
        cin>>a>>b;
        ad[a].push_back(b);
        ad[b].push_back(a);
    }
    for(int i=1;i<=N;i++)cin>>h[i];
    cin>>Q;
    for(int i=0;i<Q;i++){
        cin>>t;
        if(t==1){
            cin>>t>>a>>b;
            dfs(t,-1,a,b);
        }else{
            cin>>t;
            cout<<h[t]<<nl;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 2 ms 5208 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Incorrect 129 ms 22548 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Incorrect 129 ms 22548 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 338 ms 19632 KB Output is correct
3 Correct 1757 ms 21636 KB Output is correct
4 Correct 602 ms 21072 KB Output is correct
5 Correct 2606 ms 21076 KB Output is correct
6 Execution timed out 4014 ms 16980 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 295 ms 23636 KB Output is correct
3 Correct 1593 ms 21844 KB Output is correct
4 Correct 522 ms 22616 KB Output is correct
5 Correct 2324 ms 22916 KB Output is correct
6 Execution timed out 4040 ms 16988 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 2 ms 5208 KB Output isn't correct
5 Halted 0 ms 0 KB -