Submission #892315

# Submission time Handle Problem Language Result Execution time Memory
892315 2023-12-25T07:22:02 Z vjudge1 Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 17416 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N=2e5+5;
vector <int> g[N];
int h[N];
signed main(){
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    int q;
    cin>>q;
    if(n<=1000 && q<=1000){
        while(q--){
            int type,x,d,w;
            cin>>type;
            if(type==1){
                cin>>x>>d>>w;
                queue <int> q;
                vector <int> dis(n+1,-1);
                q.push(x);
                dis[x]=0;
                while(!q.empty()){
                    int v=q.front();
                    q.pop();
                    for(auto to : g[v]){
                        if(dis[to]==-1){
                            dis[to]=dis[v]+1;
                            q.push(to);
                        }
                    }
                }
                for(int i=1;i<=n;i++){
                    if(dis[i]<=d){
                        h[i]=(h[i]*w)%l;
                    }
                }
            }
            else{
                cin>>x;
                cout<<h[x]<<"\n";
            }
        }
     return 0;
    }
    while(q--){
        int type,x,d,w;
        cin>>type;
        if(type==1){
            cin>>x>>d>>w;
            h[x]*=w;h[x]%=l;
            if(d==1){
                for(auto to : g[x]){
                    h[to]*=w;h[to]%=l;
                }
            }
           
        }
        else{
            cin>>x;
            cout<<h[x]<<"\n";
        }
    }
    
    
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 9 ms 6492 KB Output is correct
5 Correct 11 ms 6492 KB Output is correct
6 Correct 11 ms 6492 KB Output is correct
7 Correct 11 ms 6492 KB Output is correct
8 Correct 10 ms 6492 KB Output is correct
9 Correct 3 ms 6492 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
15 Correct 3 ms 6492 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 3 ms 6404 KB Output is correct
19 Correct 3 ms 6744 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 3 ms 6316 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 3 ms 6492 KB Output is correct
27 Correct 3 ms 6488 KB Output is correct
28 Correct 3 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 773 ms 17360 KB Output is correct
3 Correct 512 ms 14340 KB Output is correct
4 Correct 646 ms 14928 KB Output is correct
5 Correct 654 ms 15768 KB Output is correct
6 Correct 636 ms 15816 KB Output is correct
7 Correct 644 ms 16212 KB Output is correct
8 Correct 622 ms 16468 KB Output is correct
9 Correct 763 ms 16116 KB Output is correct
10 Correct 548 ms 13652 KB Output is correct
11 Correct 741 ms 17416 KB Output is correct
12 Correct 522 ms 14336 KB Output is correct
13 Execution timed out 4027 ms 14216 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 773 ms 17360 KB Output is correct
3 Correct 512 ms 14340 KB Output is correct
4 Correct 646 ms 14928 KB Output is correct
5 Correct 654 ms 15768 KB Output is correct
6 Correct 636 ms 15816 KB Output is correct
7 Correct 644 ms 16212 KB Output is correct
8 Correct 622 ms 16468 KB Output is correct
9 Correct 763 ms 16116 KB Output is correct
10 Correct 548 ms 13652 KB Output is correct
11 Correct 741 ms 17416 KB Output is correct
12 Correct 522 ms 14336 KB Output is correct
13 Execution timed out 4027 ms 14216 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Incorrect 740 ms 16076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Incorrect 727 ms 16272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 9 ms 6492 KB Output is correct
5 Correct 11 ms 6492 KB Output is correct
6 Correct 11 ms 6492 KB Output is correct
7 Correct 11 ms 6492 KB Output is correct
8 Correct 10 ms 6492 KB Output is correct
9 Correct 3 ms 6492 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
15 Correct 3 ms 6492 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 3 ms 6404 KB Output is correct
19 Correct 3 ms 6744 KB Output is correct
20 Correct 3 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 3 ms 6316 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 3 ms 6492 KB Output is correct
27 Correct 3 ms 6488 KB Output is correct
28 Correct 3 ms 6492 KB Output is correct
29 Correct 2 ms 6492 KB Output is correct
30 Correct 773 ms 17360 KB Output is correct
31 Correct 512 ms 14340 KB Output is correct
32 Correct 646 ms 14928 KB Output is correct
33 Correct 654 ms 15768 KB Output is correct
34 Correct 636 ms 15816 KB Output is correct
35 Correct 644 ms 16212 KB Output is correct
36 Correct 622 ms 16468 KB Output is correct
37 Correct 763 ms 16116 KB Output is correct
38 Correct 548 ms 13652 KB Output is correct
39 Correct 741 ms 17416 KB Output is correct
40 Correct 522 ms 14336 KB Output is correct
41 Execution timed out 4027 ms 14216 KB Time limit exceeded
42 Halted 0 ms 0 KB -