# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
598516 |
2022-07-18T12:51:14 Z |
l_reho |
Regions (IOI09_regions) |
C++14 |
|
1576 ms |
131072 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int N, R, Q, root;
vector<vector<int>> graph;
vector<map<int, int>> M;
vector<vector<int>> occ;
vector<int> region;
void precompute(int curr){
vector<int> adj = graph[curr];
M[curr][region[curr]]++;
for(int a : adj){
precompute(a);
// bisogna fondere vector[a] in vector[curr]
for(auto m : M[a])
M[curr][m.first]+=m.second;
}
}
void solve(){
cin>>N>>R>>Q>>root;
graph.assign(N+1, vector<int>());
region.assign(N+1, 0);
occ.assign(R+1, vector<int>());
M.assign(N+1, map<int, int>());
region[root] = root;
occ[root].push_back(root);
for(int i = 0; i < N-1; i++){
int a, b;
cin>>a>>b;
graph[a].push_back(i+2);
occ[b].push_back(i+2);
region[i+2] = b;
}
precompute(root);
int ans = 0;
for(int i = 0; i < Q; i++){
int r1, r2;
cin>>r1>>r2;
ans = 0;
vector<int> o = occ[r1];
for(int e : o) ans += M[e][r2];
cout<<ans<<endl;
}
}
int main(){
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
312 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
648 KB |
Output isn't correct |
6 |
Incorrect |
37 ms |
5572 KB |
Output isn't correct |
7 |
Incorrect |
28 ms |
1688 KB |
Output isn't correct |
8 |
Incorrect |
34 ms |
2056 KB |
Output isn't correct |
9 |
Incorrect |
239 ms |
65792 KB |
Output isn't correct |
10 |
Incorrect |
130 ms |
20148 KB |
Output isn't correct |
11 |
Incorrect |
462 ms |
53688 KB |
Output isn't correct |
12 |
Incorrect |
607 ms |
112820 KB |
Output isn't correct |
13 |
Incorrect |
315 ms |
46376 KB |
Output isn't correct |
14 |
Incorrect |
549 ms |
91416 KB |
Output isn't correct |
15 |
Runtime error |
297 ms |
131072 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
297 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Runtime error |
428 ms |
131072 KB |
Execution killed with signal 9 |
3 |
Runtime error |
291 ms |
131072 KB |
Execution killed with signal 9 |
4 |
Incorrect |
572 ms |
80828 KB |
Output isn't correct |
5 |
Runtime error |
314 ms |
131072 KB |
Execution killed with signal 9 |
6 |
Incorrect |
952 ms |
84112 KB |
Output isn't correct |
7 |
Incorrect |
1576 ms |
55660 KB |
Output isn't correct |
8 |
Runtime error |
329 ms |
131072 KB |
Execution killed with signal 9 |
9 |
Runtime error |
602 ms |
131072 KB |
Execution killed with signal 9 |
10 |
Runtime error |
385 ms |
131072 KB |
Execution killed with signal 9 |
11 |
Runtime error |
646 ms |
131072 KB |
Execution killed with signal 9 |
12 |
Runtime error |
472 ms |
131072 KB |
Execution killed with signal 9 |
13 |
Runtime error |
486 ms |
131072 KB |
Execution killed with signal 9 |
14 |
Runtime error |
479 ms |
131072 KB |
Execution killed with signal 9 |
15 |
Runtime error |
423 ms |
131072 KB |
Execution killed with signal 9 |
16 |
Runtime error |
363 ms |
131072 KB |
Execution killed with signal 9 |
17 |
Runtime error |
487 ms |
131072 KB |
Execution killed with signal 9 |