답안 #1066989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066989 2024-08-20T09:20:37 Z pcc 참나무 (IOI23_beechtree) C++17
9 / 100
2000 ms 59216 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 2e5+10;

pii par[mxn];
vector<pii> tree[mxn];
vector<int> col[mxn];
vector<int> sub[mxn];
vector<int> ans;
int cnt[mxn];

void dfs(int now){
	sub[now].push_back(now);
	for(auto [nxt,w]:tree[now]){
		dfs(nxt);
		for(auto &i:sub[nxt])sub[now].push_back(i);
	}
	vector<int> v = sub[now];
	if(v.size() == 1){
		ans[now] = 1;
		return;
	}
	sort(v.begin()+1,v.end());
	ans[now] = 0;

	do{
		memset(cnt,0,sizeof(cnt));
		bool flag = true;
		for(int i = 1;i<v.size();i++){
			int tmp = v[i];
			auto [p,w] = par[tmp];
			int num = cnt[w];
			if(v[num] != p)flag = false;
			cnt[w]++;
		}
		if(flag)ans[now] = 1;
	}while(next_permutation(v.begin()+1,v.end()));
	return;
}

std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C){
	ans = vector<int>(N,1);
	for(int i = 1;i<N;i++){
		int p = P[i];
		tree[p].push_back(pii(i,C[i]));
		par[i] = pii(p,C[i]);
		col[C[i]].push_back(p);
	}
	dfs(0);
	return ans;
}

Compilation message

beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i = 1;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15192 KB Output is correct
2 Execution timed out 2101 ms 15196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15192 KB Output is correct
2 Correct 9 ms 15192 KB Output is correct
3 Correct 91 ms 15196 KB Output is correct
4 Correct 96 ms 15292 KB Output is correct
5 Correct 99 ms 15192 KB Output is correct
6 Correct 100 ms 15192 KB Output is correct
7 Correct 6 ms 15192 KB Output is correct
8 Correct 7 ms 15196 KB Output is correct
9 Correct 17 ms 15076 KB Output is correct
10 Correct 20 ms 15448 KB Output is correct
11 Correct 16 ms 15312 KB Output is correct
12 Correct 22 ms 15196 KB Output is correct
13 Correct 19 ms 15192 KB Output is correct
14 Correct 21 ms 15196 KB Output is correct
15 Correct 18 ms 15196 KB Output is correct
16 Correct 18 ms 15192 KB Output is correct
17 Correct 18 ms 15196 KB Output is correct
18 Correct 9 ms 15196 KB Output is correct
19 Correct 12 ms 15192 KB Output is correct
20 Correct 19 ms 15196 KB Output is correct
21 Correct 83 ms 15296 KB Output is correct
22 Correct 17 ms 15196 KB Output is correct
23 Correct 18 ms 15312 KB Output is correct
24 Correct 17 ms 15196 KB Output is correct
25 Correct 17 ms 15192 KB Output is correct
26 Correct 7 ms 15196 KB Output is correct
27 Correct 9 ms 15196 KB Output is correct
28 Correct 9 ms 15196 KB Output is correct
29 Correct 20 ms 15196 KB Output is correct
30 Correct 7 ms 15196 KB Output is correct
31 Correct 17 ms 15084 KB Output is correct
32 Correct 82 ms 15144 KB Output is correct
33 Correct 17 ms 15192 KB Output is correct
34 Correct 7 ms 15196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15192 KB Output is correct
2 Correct 9 ms 15192 KB Output is correct
3 Correct 91 ms 15196 KB Output is correct
4 Correct 96 ms 15292 KB Output is correct
5 Correct 99 ms 15192 KB Output is correct
6 Correct 100 ms 15192 KB Output is correct
7 Execution timed out 2070 ms 59216 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 15196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15192 KB Output is correct
2 Correct 9 ms 15192 KB Output is correct
3 Correct 6 ms 15192 KB Output is correct
4 Correct 7 ms 15196 KB Output is correct
5 Execution timed out 2070 ms 59216 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15192 KB Output is correct
2 Execution timed out 2101 ms 15196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15192 KB Output is correct
2 Correct 9 ms 15192 KB Output is correct
3 Correct 6 ms 15192 KB Output is correct
4 Correct 7 ms 15196 KB Output is correct
5 Correct 17 ms 15076 KB Output is correct
6 Correct 20 ms 15448 KB Output is correct
7 Correct 16 ms 15312 KB Output is correct
8 Correct 22 ms 15196 KB Output is correct
9 Correct 19 ms 15192 KB Output is correct
10 Correct 21 ms 15196 KB Output is correct
11 Correct 18 ms 15196 KB Output is correct
12 Correct 18 ms 15192 KB Output is correct
13 Correct 18 ms 15196 KB Output is correct
14 Correct 9 ms 15196 KB Output is correct
15 Correct 12 ms 15192 KB Output is correct
16 Correct 19 ms 15196 KB Output is correct
17 Correct 83 ms 15296 KB Output is correct
18 Correct 17 ms 15196 KB Output is correct
19 Correct 18 ms 15312 KB Output is correct
20 Correct 17 ms 15196 KB Output is correct
21 Correct 17 ms 15192 KB Output is correct
22 Correct 7 ms 15196 KB Output is correct
23 Correct 9 ms 15196 KB Output is correct
24 Correct 9 ms 15196 KB Output is correct
25 Execution timed out 2024 ms 15448 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15192 KB Output is correct
2 Execution timed out 2101 ms 15196 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15192 KB Output is correct
2 Correct 9 ms 15192 KB Output is correct
3 Correct 6 ms 15192 KB Output is correct
4 Correct 7 ms 15196 KB Output is correct
5 Correct 17 ms 15076 KB Output is correct
6 Correct 20 ms 15448 KB Output is correct
7 Correct 16 ms 15312 KB Output is correct
8 Correct 22 ms 15196 KB Output is correct
9 Correct 19 ms 15192 KB Output is correct
10 Correct 21 ms 15196 KB Output is correct
11 Correct 18 ms 15196 KB Output is correct
12 Correct 18 ms 15192 KB Output is correct
13 Correct 18 ms 15196 KB Output is correct
14 Correct 9 ms 15196 KB Output is correct
15 Correct 12 ms 15192 KB Output is correct
16 Correct 19 ms 15196 KB Output is correct
17 Correct 83 ms 15296 KB Output is correct
18 Correct 17 ms 15196 KB Output is correct
19 Correct 18 ms 15312 KB Output is correct
20 Correct 17 ms 15196 KB Output is correct
21 Correct 17 ms 15192 KB Output is correct
22 Correct 7 ms 15196 KB Output is correct
23 Correct 9 ms 15196 KB Output is correct
24 Correct 9 ms 15196 KB Output is correct
25 Execution timed out 2024 ms 15448 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15192 KB Output is correct
2 Execution timed out 2101 ms 15196 KB Time limit exceeded
3 Halted 0 ms 0 KB -