Submission #102110

# Submission time Handle Problem Language Result Execution time Memory
102110 2019-03-22T11:49:52 Z figter001 Regions (IOI09_regions) C++17
0 / 100
10 ms 4992 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]]++;
	}

	if(p != -1){
		for(int i=1;i<=R;i++)
			dp[p][i] += dp[u][i];
	}
	for(int i=1;i<=R;i++){
		ans[r[u]][i] += dp[u][i];
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	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] << '\n';
		// scanf("%d%d",&a,&b);
		// printf("%d\n", ans[a][b]);
		fflush(stdout);
	}
}

Compilation message

regions.cpp: In function 'int main()':
regions.cpp:35:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("input.txt","r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
2 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
3 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
4 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
5 Incorrect 9 ms 4992 KB Unexpected end of file - int32 expected
6 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
7 Incorrect 8 ms 4992 KB Unexpected end of file - int32 expected
8 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
9 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
10 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
11 Incorrect 8 ms 4992 KB Unexpected end of file - int32 expected
12 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
13 Incorrect 8 ms 4992 KB Unexpected end of file - int32 expected
14 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
15 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 4992 KB Unexpected end of file - int32 expected
2 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
4 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
5 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
6 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
7 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
8 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
9 Incorrect 8 ms 4992 KB Unexpected end of file - int32 expected
10 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected
11 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
12 Incorrect 8 ms 4992 KB Unexpected end of file - int32 expected
13 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
14 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected
15 Incorrect 10 ms 4992 KB Unexpected end of file - int32 expected
16 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
17 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected