#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
typedef long long ll;
// #define int ll
const int MOD = 1e9+7;
const int R = 25001;
int n, r, q;
vector<vector<int>> adj;
vector<int> region;
vector<int> active(R);
vector<vector<int>> answer(R, vector<int>(R));
// void dfs(int node, int par){
// for(int i = 0; i <= r; ++i){
// // if(i==region[node]) continue;
// answer[region[node]][i] += active[i];
// }
// active[region[node]]++;
// for(int &c: adj[node]){
// if(c!=par){
// dfs(c, node);
// }
// }
// active[region[node]]--;
// }
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
cin >> n >> r >> q;
adj.resize(n); region.resize(n);
cin >> region[0];
for(int i = 1; i < n; ++i){
int supervisor, home; cin >> supervisor >> home;
adj[--supervisor].push_back(i);
region[i] = home;
}
// dfs(0, -1);
for(int i = 0; i < q; ++i){
int e1, e2; cin >> e1 >> e2;
cout << answer[e2][e1] << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |