# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338218 | 2020-12-22T18:19:37 Z | aryan12 | Birthday gift (IZhO18_treearray) | C++17 | 4 ms | 5100 KB |
#include <bits/stdc++.h> using namespace std; //for 56 points const long long N = 2e5 + 10; vector<long long> g[N]; long long tim = 0; long long Start[N], End[N]; void dfs(long long node, long long par) { Start[node] = ++tim; for(long long i = 0; i < g[node].size(); i++) { if(g[node][i] != par) { dfs(g[node][i], node); } } End[node] = ++tim; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, m, q; cin >> n >> m >> q; for(long long i = 0; i < n - 1; i++) { long long v, u; cin >> v >> u; g[v].push_back(u); g[u].push_back(v); } dfs(1, -1); long long a[m + 1]; for(long long i = 1; i <= m; i++) { cin >> a[i]; } for(long long i = 1; i <= q; i++) { long long command; cin >> command; if(command == 1) { long long idx, val; cin >> idx >> val; a[idx] = val; } else { long long l, r, v; cin >> l >> r >> v; long long f = 0; for(long long j = l; j <= r; j++) { if(Start[v] < Start[a[j]] && End[v] > End[a[j]]) { cout << j << " " << j << "\n"; f = 1; break; } } if(f == 0) { cout << "-1 -1" << "\n"; } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Wrong range. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Wrong range. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Wrong range. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Wrong range. |
2 | Halted | 0 ms | 0 KB | - |