Submission #102112

# Submission time Handle Problem Language Result Execution time Memory
102112 2019-03-22T13:14:20 Z figter001 Regions (IOI09_regions) C++17
5 / 100
241 ms 59584 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[rax][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 8 ms 5120 KB Output is correct
3 Correct 8 ms 5120 KB Output is correct
4 Correct 9 ms 5248 KB Output is correct
5 Correct 15 ms 6064 KB Output is correct
6 Incorrect 23 ms 7424 KB Output isn't correct
7 Runtime error 15 ms 11704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 17 ms 12928 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 23 ms 11048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 27 ms 11924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 25 ms 14712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 26 ms 11768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 29 ms 10876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 33 ms 13560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 42 ms 20152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 57 ms 14956 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 65 ms 16120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 84 ms 18744 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 32 ms 11640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 53 ms 12664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 65 ms 12940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 59 ms 13944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 85 ms 18392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 151 ms 19844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 221 ms 22132 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 225 ms 18548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 241 ms 23192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 228 ms 22140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 231 ms 21664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 230 ms 27044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 211 ms 59584 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 198 ms 23996 KB Execution killed with signal 11 (could be triggered by violating memory limits)