# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1050421 |
2024-08-09T09:20:29 Z |
Ludissey |
Regions (IOI09_regions) |
C++17 |
|
693 ms |
131072 KB |
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using namespace std;
vector<vector<int>> child;
vector<unordered_map<int,int>> kp;
vector<int> parent;
vector<int> rg;
vector<vector<int>> pr;
vector<vector<pair<int,int>>> qPR;
vector<unordered_map<int,bool>> qHAS;
vector<unordered_map<int,int>> mp;
vector<int> out;
int need;
int sq;
unordered_map<int,int> kpp(int x){
vector<unordered_map<int,int>> mpVEC;
mp[x][rg[x]]=1;
for (auto u : child[x]) mpVEC.push_back(kpp(u));
for (int i = 0; i < sz(mpVEC); i++)
{
for (auto u : mpVEC[i])
{
mp[x][u.first]+=u.second;
}
}
return mp[x];
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int N,R,Q; cin >> N >> R >> Q;
child.resize(N);
kp.resize(N);
parent.resize(N);
mp.resize(N);
qHAS.resize(R);
rg.resize(N);
pr.resize(R);
sq=600;
cin >> rg[0]; rg[0]--;
pr[rg[0]].push_back(0);
for (int i = 1; i < N; i++)
{
cin >> parent[i] >> rg[i]; parent[i]--; rg[i]--;
child[parent[i]].push_back(i);
pr[rg[i]].push_back(i);
}
qPR.resize(R);
out.resize(Q);
kpp(0);
for (int i = 0; i < Q; i++)
{
int e1,e2; cin >> e1>>e2; e1--; e2--;
int sm=0;
for (auto x : pr[e1])
{
sm+=mp[x][e2];
}
cout << sm << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
1072 KB |
Output is correct |
6 |
Correct |
20 ms |
6572 KB |
Output is correct |
7 |
Correct |
23 ms |
2896 KB |
Output is correct |
8 |
Correct |
24 ms |
5208 KB |
Output is correct |
9 |
Correct |
163 ms |
66640 KB |
Output is correct |
10 |
Correct |
93 ms |
19728 KB |
Output is correct |
11 |
Correct |
236 ms |
51880 KB |
Output is correct |
12 |
Runtime error |
197 ms |
131072 KB |
Execution killed with signal 9 |
13 |
Correct |
271 ms |
51088 KB |
Output is correct |
14 |
Correct |
693 ms |
106936 KB |
Output is correct |
15 |
Runtime error |
179 ms |
131072 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
182 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Runtime error |
258 ms |
131072 KB |
Execution killed with signal 9 |
3 |
Runtime error |
172 ms |
131072 KB |
Execution killed with signal 9 |
4 |
Runtime error |
210 ms |
131072 KB |
Execution killed with signal 9 |
5 |
Runtime error |
218 ms |
131072 KB |
Execution killed with signal 9 |
6 |
Runtime error |
229 ms |
131072 KB |
Execution killed with signal 9 |
7 |
Runtime error |
217 ms |
131072 KB |
Execution killed with signal 9 |
8 |
Runtime error |
201 ms |
131072 KB |
Execution killed with signal 9 |
9 |
Runtime error |
219 ms |
131072 KB |
Execution killed with signal 9 |
10 |
Runtime error |
184 ms |
131072 KB |
Execution killed with signal 9 |
11 |
Runtime error |
200 ms |
131072 KB |
Execution killed with signal 9 |
12 |
Runtime error |
195 ms |
131072 KB |
Execution killed with signal 9 |
13 |
Runtime error |
216 ms |
131072 KB |
Execution killed with signal 9 |
14 |
Runtime error |
193 ms |
131072 KB |
Execution killed with signal 9 |
15 |
Runtime error |
182 ms |
131072 KB |
Execution killed with signal 9 |
16 |
Runtime error |
144 ms |
131072 KB |
Execution killed with signal 9 |
17 |
Runtime error |
205 ms |
131072 KB |
Execution killed with signal 9 |