Submission #785437

# Submission time Handle Problem Language Result Execution time Memory
785437 2023-07-17T09:07:26 Z kebine Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 19008 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int dis[200005], h[200005];
vector<int> adjl[200005];
int n, l, a, b;

int kali(int a, int b) {
  return ((a%l)*(b%l))%l;
}

void bfs(int start, int d, int w) {
  queue<int> q;
  memset(dis, -1, sizeof(dis));
  q.push(start);
  dis[start] = 0;
  h[start] = kali(h[start], w);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();

    for (auto i: adjl[cur]) {
      if (dis[i] == -1) {
        dis[i] = dis[cur]+1;
        if (dis[i] <= d) {
          q.push(i);
          h[i] = kali(h[i], w);
        }
      }
    }
  }
}

signed main() {
  cin >> n >> l;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) cin >> h[i];

  int q, t, x, d, w;
  cin >> q;
  while (q--) {
    cin >> t;
    if (t == 1) {
      cin >> x >> d >> w;
      bfs(x, d, w);
    }
    else if (t == 2) {
      cin >> x;
      cout << h[x]%l << endl;
    }
  }

}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 3 ms 6484 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 21 ms 6616 KB Output is correct
5 Correct 19 ms 6616 KB Output is correct
6 Correct 24 ms 6624 KB Output is correct
7 Correct 26 ms 6620 KB Output is correct
8 Correct 26 ms 6612 KB Output is correct
9 Correct 16 ms 6580 KB Output is correct
10 Correct 17 ms 6644 KB Output is correct
11 Correct 17 ms 6572 KB Output is correct
12 Correct 16 ms 6580 KB Output is correct
13 Correct 16 ms 6572 KB Output is correct
14 Correct 16 ms 6476 KB Output is correct
15 Correct 16 ms 6484 KB Output is correct
16 Correct 16 ms 6576 KB Output is correct
17 Correct 17 ms 6580 KB Output is correct
18 Correct 15 ms 6580 KB Output is correct
19 Correct 16 ms 6484 KB Output is correct
20 Correct 17 ms 6484 KB Output is correct
21 Correct 16 ms 6484 KB Output is correct
22 Correct 16 ms 6484 KB Output is correct
23 Correct 17 ms 6484 KB Output is correct
24 Correct 17 ms 6484 KB Output is correct
25 Correct 16 ms 6580 KB Output is correct
26 Correct 17 ms 6576 KB Output is correct
27 Correct 17 ms 6612 KB Output is correct
28 Correct 16 ms 6580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 1794 ms 19008 KB Output is correct
3 Execution timed out 4066 ms 15792 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 1794 ms 19008 KB Output is correct
3 Execution timed out 4066 ms 15792 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 2136 ms 15332 KB Output is correct
3 Execution timed out 4066 ms 14416 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 2153 ms 17944 KB Output is correct
3 Execution timed out 4051 ms 14544 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 3 ms 6484 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 21 ms 6616 KB Output is correct
5 Correct 19 ms 6616 KB Output is correct
6 Correct 24 ms 6624 KB Output is correct
7 Correct 26 ms 6620 KB Output is correct
8 Correct 26 ms 6612 KB Output is correct
9 Correct 16 ms 6580 KB Output is correct
10 Correct 17 ms 6644 KB Output is correct
11 Correct 17 ms 6572 KB Output is correct
12 Correct 16 ms 6580 KB Output is correct
13 Correct 16 ms 6572 KB Output is correct
14 Correct 16 ms 6476 KB Output is correct
15 Correct 16 ms 6484 KB Output is correct
16 Correct 16 ms 6576 KB Output is correct
17 Correct 17 ms 6580 KB Output is correct
18 Correct 15 ms 6580 KB Output is correct
19 Correct 16 ms 6484 KB Output is correct
20 Correct 17 ms 6484 KB Output is correct
21 Correct 16 ms 6484 KB Output is correct
22 Correct 16 ms 6484 KB Output is correct
23 Correct 17 ms 6484 KB Output is correct
24 Correct 17 ms 6484 KB Output is correct
25 Correct 16 ms 6580 KB Output is correct
26 Correct 17 ms 6576 KB Output is correct
27 Correct 17 ms 6612 KB Output is correct
28 Correct 16 ms 6580 KB Output is correct
29 Correct 3 ms 6484 KB Output is correct
30 Correct 1794 ms 19008 KB Output is correct
31 Execution timed out 4066 ms 15792 KB Time limit exceeded
32 Halted 0 ms 0 KB -