답안 #102108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102108 2019-03-22T11:47:48 Z figter001 Regions (IOI09_regions) C++17
0 / 100
9 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++){
		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);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
regions.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a,&b);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4892 KB Unexpected end of file - int32 expected
2 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
4 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
5 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
6 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected
7 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
8 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
9 Incorrect 4 ms 4992 KB Unexpected end of file - int32 expected
10 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
11 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
12 Incorrect 5 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 4992 KB Unexpected end of file - int32 expected
15 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected
2 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
3 Incorrect 6 ms 4912 KB Unexpected end of file - int32 expected
4 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
5 Incorrect 5 ms 4992 KB Unexpected end of file - int32 expected
6 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
7 Incorrect 6 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 9 ms 4912 KB Unexpected end of file - int32 expected
11 Incorrect 5 ms 4992 KB Unexpected end of file - int32 expected
12 Incorrect 6 ms 4992 KB Unexpected end of file - int32 expected
13 Incorrect 5 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
16 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected
17 Incorrect 7 ms 4992 KB Unexpected end of file - int32 expected