#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]<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
200 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
328 KB |
Output isn't correct |
5 |
Incorrect |
11 ms |
328 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
1096 KB |
Output isn't correct |
7 |
Incorrect |
15 ms |
1352 KB |
Output isn't correct |
8 |
Incorrect |
52 ms |
1864 KB |
Output isn't correct |
9 |
Incorrect |
55 ms |
6344 KB |
Output isn't correct |
10 |
Incorrect |
133 ms |
17160 KB |
Output isn't correct |
11 |
Incorrect |
75 ms |
16644 KB |
Output isn't correct |
12 |
Incorrect |
187 ms |
36204 KB |
Output isn't correct |
13 |
Incorrect |
169 ms |
33280 KB |
Output isn't correct |
14 |
Incorrect |
105 ms |
25164 KB |
Output isn't correct |
15 |
Incorrect |
201 ms |
39748 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1046 ms |
62516 KB |
Output isn't correct |
2 |
Incorrect |
821 ms |
72952 KB |
Output isn't correct |
3 |
Incorrect |
1381 ms |
96104 KB |
Output isn't correct |
4 |
Runtime error |
64 ms |
131076 KB |
Execution killed with signal 9 |
5 |
Runtime error |
63 ms |
131076 KB |
Execution killed with signal 9 |
6 |
Runtime error |
68 ms |
131076 KB |
Execution killed with signal 9 |
7 |
Runtime error |
66 ms |
131076 KB |
Execution killed with signal 9 |
8 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |
9 |
Runtime error |
64 ms |
131076 KB |
Execution killed with signal 9 |
10 |
Runtime error |
66 ms |
131076 KB |
Execution killed with signal 9 |
11 |
Runtime error |
60 ms |
131076 KB |
Execution killed with signal 9 |
12 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |
13 |
Runtime error |
67 ms |
131076 KB |
Execution killed with signal 9 |
14 |
Runtime error |
66 ms |
131076 KB |
Execution killed with signal 9 |
15 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |
16 |
Runtime error |
65 ms |
131076 KB |
Execution killed with signal 9 |
17 |
Runtime error |
64 ms |
131076 KB |
Execution killed with signal 9 |