#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
int main(){
int N,R,Q;
cin>>N>>R>>Q;
vector<int>zero(R,0);
vector<vector<int> >max;
for(int i=0;i<N;i++){
max.push_back(zero);
}
vector<int>padre(N,-1);
vector<int>region(N);
int a,b;
cin>>a;
region[0]=a-1;
for(int i=1;i<N;i++){
cin>>a>>b;
padre[i]=a-1;
region[i]=b-1;
max[region[a-1]][b-1]++;
if(padre[a-1]!=-1){
max[region[padre[a-1]]][b-1]++;
}
}
for(int i=0;i<Q;i++){
cin>>a>>b;
cout<<max[a-1][b-1]<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
264 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
200 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
200 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
328 KB |
Output isn't correct |
6 |
Incorrect |
15 ms |
1096 KB |
Output isn't correct |
7 |
Incorrect |
30 ms |
1224 KB |
Output isn't correct |
8 |
Incorrect |
37 ms |
1864 KB |
Output isn't correct |
9 |
Incorrect |
57 ms |
6344 KB |
Output isn't correct |
10 |
Incorrect |
56 ms |
17156 KB |
Output isn't correct |
11 |
Incorrect |
149 ms |
16732 KB |
Output isn't correct |
12 |
Incorrect |
187 ms |
36224 KB |
Output isn't correct |
13 |
Incorrect |
160 ms |
33280 KB |
Output isn't correct |
14 |
Incorrect |
186 ms |
25136 KB |
Output isn't correct |
15 |
Incorrect |
264 ms |
39640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
802 ms |
62456 KB |
Output isn't correct |
2 |
Incorrect |
941 ms |
72816 KB |
Output isn't correct |
3 |
Incorrect |
1424 ms |
95984 KB |
Output isn't correct |
4 |
Runtime error |
67 ms |
131076 KB |
Execution killed with signal 9 |
5 |
Runtime error |
64 ms |
131076 KB |
Execution killed with signal 9 |
6 |
Runtime error |
63 ms |
131076 KB |
Execution killed with signal 9 |
7 |
Runtime error |
67 ms |
131076 KB |
Execution killed with signal 9 |
8 |
Runtime error |
69 ms |
131076 KB |
Execution killed with signal 9 |
9 |
Runtime error |
67 ms |
131076 KB |
Execution killed with signal 9 |
10 |
Runtime error |
64 ms |
131076 KB |
Execution killed with signal 9 |
11 |
Runtime error |
61 ms |
131076 KB |
Execution killed with signal 9 |
12 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |
13 |
Runtime error |
60 ms |
131076 KB |
Execution killed with signal 9 |
14 |
Runtime error |
66 ms |
131076 KB |
Execution killed with signal 9 |
15 |
Runtime error |
66 ms |
131076 KB |
Execution killed with signal 9 |
16 |
Runtime error |
61 ms |
131072 KB |
Execution killed with signal 9 |
17 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |