Submission #102114

# Submission time Handle Problem Language Result Execution time Memory
102114 2019-03-22T13:19:09 Z figter001 Regions (IOI09_regions) C++17
15 / 100
2020 ms 131072 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 2e5 + 50;
const int rax = 510;

int r[nax],dp[nax][rax],ans[rax][rax];
int n,R,q;
vector<int> g[nax];

void dfs(int u,int p){

	for(int v : g[u]){
		if(v == p)
			continue;
		dfs(v,u);
		dp[u][r[v]]++;
		for(int i=1;i<=R;i++)
			dp[u][i] += dp[v][i];
	}
	for(int i=1;i<=R;i++)
		ans[r[u]][i] += dp[u][i];
}

int main(){
	cin>>n>>R>>q;
	cin>>r[1];
	for(int i=2;i<=n;i++){
		int p;
		cin>>p>>r[i];
		g[p].push_back(i);
	}
	dfs(1,0);
	int a,b;
	for(int i=0;i<q;i++){
		cin>>a>>b;
		cout << ans[a][b] << endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4992 KB Output is correct
2 Correct 10 ms 5120 KB Output is correct
3 Correct 10 ms 5120 KB Output is correct
4 Correct 9 ms 5248 KB Output is correct
5 Correct 11 ms 6144 KB Output is correct
6 Correct 25 ms 7168 KB Output is correct
7 Correct 40 ms 8320 KB Output is correct
8 Correct 29 ms 9484 KB Output is correct
9 Correct 41 ms 16256 KB Output is correct
10 Correct 107 ms 25720 KB Output is correct
11 Correct 136 ms 36088 KB Output is correct
12 Correct 188 ms 46888 KB Output is correct
13 Correct 157 ms 41128 KB Output is correct
14 Correct 221 ms 64440 KB Output is correct
15 Correct 251 ms 90388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 204 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 239 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 239 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Incorrect 534 ms 66824 KB Output isn't correct
5 Incorrect 742 ms 83624 KB Output isn't correct
6 Incorrect 1273 ms 111692 KB Output isn't correct
7 Runtime error 1047 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 920 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 672 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 1283 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 1830 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 1371 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 928 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 2020 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 933 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 1425 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 1355 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)