답안 #102113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102113 2019-03-22T13:16:57 Z figter001 Regions (IOI09_regions) C++17
0 / 100
2062 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++)
			ans[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;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 5164 KB Output isn't correct
2 Incorrect 7 ms 4992 KB Output isn't correct
3 Incorrect 11 ms 5248 KB Output isn't correct
4 Incorrect 13 ms 5504 KB Output isn't correct
5 Incorrect 15 ms 6912 KB Output isn't correct
6 Incorrect 23 ms 7680 KB Output isn't correct
7 Incorrect 24 ms 8960 KB Output isn't correct
8 Incorrect 39 ms 10032 KB Output isn't correct
9 Incorrect 67 ms 16640 KB Output isn't correct
10 Incorrect 101 ms 26104 KB Output isn't correct
11 Incorrect 143 ms 36600 KB Output isn't correct
12 Incorrect 184 ms 47048 KB Output isn't correct
13 Incorrect 218 ms 49400 KB Output isn't correct
14 Incorrect 260 ms 66732 KB Output isn't correct
15 Incorrect 258 ms 90360 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 262 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 242 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 229 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Incorrect 490 ms 66720 KB Output isn't correct
5 Incorrect 684 ms 82988 KB Output isn't correct
6 Incorrect 1393 ms 111720 KB Output isn't correct
7 Runtime error 1123 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 869 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 639 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 1126 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 2003 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 1516 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 876 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 2062 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 964 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 1604 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 1492 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)