# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100355 |
2024-10-13T14:55:24 Z |
vjudge1 |
Regions (IOI09_regions) |
C++17 |
|
1154 ms |
72520 KB |
#include<bits/stdc++.h>
using namespace std;
int n,r,q,ly[200005],h[200005],dp[2505][2505];
vector<int>v[200005],c[200005];
void dfs(int x)
{
for(auto i:v[x])
{
if(ly[x]>ly[i])continue;
dfs(i);
if(h[x]!=h[i])dp[h[x]][h[i]]++;
for(int y=1;y<=r;y++)
{
if(h[i]==y||h[x]==y)continue;
dp[h[x]][y]+=dp[h[i]][y];
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>r>>q;
int hm,sp;
cin>>hm;
h[1]=hm;
c[hm].push_back(1);
for(int x=2;x<=n;x++)
{
cin>>sp>>hm;
v[sp].push_back(x);
v[x].push_back(sp);
h[x]=hm;
ly[x]=ly[sp]+1;
c[hm].push_back(x);
}
dfs(1);
while(q--)
{
int l,r;
cin>>l>>r;
cout<<dp[l][r]<<'\n'<<flush;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
12880 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
12880 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
12880 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
12880 KB |
Output isn't correct |
5 |
Incorrect |
9 ms |
12880 KB |
Output isn't correct |
6 |
Incorrect |
13 ms |
13648 KB |
Output isn't correct |
7 |
Incorrect |
26 ms |
14928 KB |
Output isn't correct |
8 |
Incorrect |
28 ms |
15096 KB |
Output isn't correct |
9 |
Incorrect |
31 ms |
15440 KB |
Output isn't correct |
10 |
Incorrect |
67 ms |
16464 KB |
Output isn't correct |
11 |
Incorrect |
85 ms |
14172 KB |
Output isn't correct |
12 |
Incorrect |
105 ms |
18000 KB |
Output isn't correct |
13 |
Incorrect |
111 ms |
16976 KB |
Output isn't correct |
14 |
Incorrect |
122 ms |
15952 KB |
Output isn't correct |
15 |
Incorrect |
162 ms |
19536 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
697 ms |
18768 KB |
Output isn't correct |
2 |
Incorrect |
805 ms |
18000 KB |
Output isn't correct |
3 |
Incorrect |
1154 ms |
20944 KB |
Output isn't correct |
4 |
Runtime error |
33 ms |
32328 KB |
Execution killed with signal 11 |
5 |
Runtime error |
29 ms |
28752 KB |
Execution killed with signal 11 |
6 |
Runtime error |
41 ms |
38224 KB |
Execution killed with signal 11 |
7 |
Runtime error |
37 ms |
31304 KB |
Execution killed with signal 11 |
8 |
Runtime error |
44 ms |
35156 KB |
Execution killed with signal 11 |
9 |
Runtime error |
61 ms |
38472 KB |
Execution killed with signal 11 |
10 |
Runtime error |
62 ms |
40520 KB |
Execution killed with signal 11 |
11 |
Runtime error |
69 ms |
43112 KB |
Execution killed with signal 11 |
12 |
Runtime error |
61 ms |
41264 KB |
Execution killed with signal 11 |
13 |
Runtime error |
63 ms |
41288 KB |
Execution killed with signal 11 |
14 |
Runtime error |
67 ms |
42312 KB |
Execution killed with signal 11 |
15 |
Runtime error |
73 ms |
49480 KB |
Execution killed with signal 11 |
16 |
Runtime error |
101 ms |
72520 KB |
Execution killed with signal 11 |
17 |
Runtime error |
66 ms |
42472 KB |
Execution killed with signal 11 |