Submission #785639

# Submission time Handle Problem Language Result Execution time Memory
785639 2023-07-17T10:57:42 Z devariaota Sprinkler (JOI22_sprinkler) C++17
0 / 100
4000 ms 17420 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define keish                             ios_base::sync_with_stdio(0);       cin.tie(0); cout.tie(0)
      
using namespace std;

int n, l, q, u, v, t, x, d, w, lim;

signed main(){
      keish;
      cin >> n >> l;
      vector<vector<int>> e(n);
      for(int i = 1; i < n; i++){
            cin >> u >> v; u--, v--;
            e[u].push_back(v);
            e[v].push_back(u);
      }

      vector<int> a(n);
      for(auto &x : a) cin >> x;

      function<void(int, int)> dfs = [&](int u, int d){
            if(d > lim) return;
            for(auto v : e[u]){
                  (a[v] *= w) %= l;
                  dfs(v, d + 1);
            }
      };

      cin >> q;
      while(q--){
            cin >> t;
            if(t == 1){
                  cin >> x >> lim >> w; x--;
                  (a[x] *= w) %= l;
                  if(lim > 0){
                        dfs(x, 1);
                  }
            }else{      
                  cin >> x; x--;
                  cout << a[x] << '\n';
            }
      }
}     
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 165 ms 17356 KB Output is correct
3 Correct 225 ms 14228 KB Output is correct
4 Correct 169 ms 14712 KB Output is correct
5 Correct 178 ms 15780 KB Output is correct
6 Correct 177 ms 15744 KB Output is correct
7 Correct 175 ms 16252 KB Output is correct
8 Correct 161 ms 16352 KB Output is correct
9 Correct 162 ms 16172 KB Output is correct
10 Correct 194 ms 13132 KB Output is correct
11 Correct 151 ms 17420 KB Output is correct
12 Correct 224 ms 14192 KB Output is correct
13 Execution timed out 4058 ms 14160 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 165 ms 17356 KB Output is correct
3 Correct 225 ms 14228 KB Output is correct
4 Correct 169 ms 14712 KB Output is correct
5 Correct 178 ms 15780 KB Output is correct
6 Correct 177 ms 15744 KB Output is correct
7 Correct 175 ms 16252 KB Output is correct
8 Correct 161 ms 16352 KB Output is correct
9 Correct 162 ms 16172 KB Output is correct
10 Correct 194 ms 13132 KB Output is correct
11 Correct 151 ms 17420 KB Output is correct
12 Correct 224 ms 14192 KB Output is correct
13 Execution timed out 4058 ms 14160 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 4050 ms 12756 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -