# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156122 |
2019-10-03T14:51:55 Z |
Nnandi |
Regions (IOI09_regions) |
C++14 |
|
1511 ms |
32888 KB |
#include <bits/stdc++.h>
#define ll long long
#define ft(n,i) for (ll i=0;i<n;i++)
#define tft(n,l,i) for (ll i=l;i<n;i++)
#define vi vector<ll>
using namespace std;
vi h,s;
vector<vi > graph;
ll to[510][510], most[510];
void bej(ll x)
{
most[h[x]]++;
ft (510,i) to[i][h[x]]+=most[i];
for (ll f: graph[x])
{
bej(f);
}
most[h[x]]--;
}
int main()
{
ios::sync_with_stdio(0);
ll n,r,q; cin>>n>>r>>q; h.assign(n+1,0); s.assign(n+1,0);
graph.assign(n+1,vi());
cin>>h[1];
tft(n+1,2,i)
{
cin>>s[i]>>h[i];
graph[s[i]].push_back(i);
}
bej(1);
ft (q,i)
{
ll a,b; cin>>a>>b; cout<<to[a][b]<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2296 KB |
Output is correct |
2 |
Correct |
4 ms |
2424 KB |
Output is correct |
3 |
Correct |
6 ms |
2296 KB |
Output is correct |
4 |
Correct |
8 ms |
2424 KB |
Output is correct |
5 |
Correct |
12 ms |
2296 KB |
Output is correct |
6 |
Correct |
25 ms |
2428 KB |
Output is correct |
7 |
Correct |
41 ms |
2552 KB |
Output is correct |
8 |
Correct |
45 ms |
2552 KB |
Output is correct |
9 |
Correct |
62 ms |
2808 KB |
Output is correct |
10 |
Correct |
109 ms |
3064 KB |
Output is correct |
11 |
Correct |
143 ms |
3496 KB |
Output is correct |
12 |
Correct |
164 ms |
3960 KB |
Output is correct |
13 |
Correct |
176 ms |
3732 KB |
Output is correct |
14 |
Correct |
249 ms |
4392 KB |
Output is correct |
15 |
Correct |
284 ms |
6452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
815 ms |
8044 KB |
Output is correct |
2 |
Correct |
880 ms |
7340 KB |
Output is correct |
3 |
Correct |
1511 ms |
9908 KB |
Output is correct |
4 |
Runtime error |
19 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
22 ms |
9976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
32 ms |
11432 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
35 ms |
13896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
48 ms |
18680 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
70 ms |
25208 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
80 ms |
28436 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
92 ms |
28664 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
89 ms |
31352 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
87 ms |
30456 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
93 ms |
30732 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
93 ms |
32808 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
94 ms |
32888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
92 ms |
32760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |