Submission #964284

# Submission time Handle Problem Language Result Execution time Memory
964284 2024-04-16T14:49:12 Z rolandpetrean Sprinkler (JOI22_sprinkler) C++17
9 / 100
274 ms 33216 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll

#define endl '\n'
#define pb push_back
using pi = array<int, 2>;

const int N = 2e5 + 5;
vector<int> adj[N];
int par[N];

int h[N], wch[N];

void dfs(int u) {
  for (int v : adj[u]) {
    if (v == par[u]) continue;
    par[v] = u;
    dfs(v);
  }
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, l;
  cin >> n >> l;
  
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  for (int i = 0; i <= n; ++i) wch[i] = 1;
  
  dfs(1);
  
  for (int i = 1; i <= n; ++i) cin >> h[i];
  
  int q;
  cin >> q;
  
  while (q--) {
    int t;
    cin >> t;
    
    if (t == 1) {
      int u, d, w;
      cin >> u >> d >> w;
      
      assert(d <= 1);
      h[u] = h[u] * w % l;
      if (d == 1) {
        h[par[u]] = h[par[u]] * w % l;
        wch[u] = wch[u] * w % l;
      }
    } else {
      int u;
      cin >> u;
      
      int ans = h[u];
      ans = ans * wch[par[u]] % l;
      cout << ans << endl;
    }
  }
}
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 14936 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 190 ms 28848 KB Output is correct
3 Correct 274 ms 29472 KB Output is correct
4 Correct 233 ms 31436 KB Output is correct
5 Correct 188 ms 29348 KB Output is correct
6 Correct 233 ms 28744 KB Output is correct
7 Correct 171 ms 29540 KB Output is correct
8 Correct 149 ms 29760 KB Output is correct
9 Correct 206 ms 33076 KB Output is correct
10 Correct 210 ms 33216 KB Output is correct
11 Correct 198 ms 28708 KB Output is correct
12 Correct 186 ms 29396 KB Output is correct
13 Correct 194 ms 29284 KB Output is correct
14 Correct 176 ms 29968 KB Output is correct
15 Correct 199 ms 29048 KB Output is correct
16 Correct 197 ms 29588 KB Output is correct
17 Correct 172 ms 30292 KB Output is correct
18 Correct 2 ms 7512 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 3 ms 7580 KB Output is correct
21 Correct 2 ms 7516 KB Output is correct
22 Correct 2 ms 7520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 190 ms 28848 KB Output is correct
3 Correct 274 ms 29472 KB Output is correct
4 Correct 233 ms 31436 KB Output is correct
5 Correct 188 ms 29348 KB Output is correct
6 Correct 233 ms 28744 KB Output is correct
7 Correct 171 ms 29540 KB Output is correct
8 Correct 149 ms 29760 KB Output is correct
9 Correct 206 ms 33076 KB Output is correct
10 Correct 210 ms 33216 KB Output is correct
11 Correct 198 ms 28708 KB Output is correct
12 Correct 186 ms 29396 KB Output is correct
13 Correct 194 ms 29284 KB Output is correct
14 Correct 176 ms 29968 KB Output is correct
15 Correct 199 ms 29048 KB Output is correct
16 Correct 197 ms 29588 KB Output is correct
17 Correct 172 ms 30292 KB Output is correct
18 Correct 2 ms 7512 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 3 ms 7580 KB Output is correct
21 Correct 2 ms 7516 KB Output is correct
22 Correct 2 ms 7520 KB Output is correct
23 Runtime error 9 ms 14940 KB Execution killed with signal 6
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 15044 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 15164 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 14936 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -