# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
477611 | Abrar_Al_Samit | Regions (IOI09_regions) | C++17 | 8077 ms | 28592 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
vector <int> g[maxn];
int H[maxn], ans, in[maxn], out[maxn], timer;
vector <int> reg[maxn];
void Euler(int v, int p ){
in[v] = timer++;
for(auto it : g[v]) if(it!=p) {
Euler(it, v);
}
out[v] = timer++;
}
bool anc(int x, int y) {
return in[x]<=in[y] && out[x]>=out[y];
}
int main() {
int N, R, Q; cin >> N >> R >> Q;
cin >> H[1];
reg[H[1]].push_back(1);
for(int i=2; i<=N; ++i) {
int p; cin >> p >> H[i];
g[p].push_back(i);
g[i].push_back(p);
reg[H[i]].push_back(i);
}
Euler(1, 1);
while(Q--) {
int r1, r2; cin >> r1 >> r2;
int ans = 0;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |