답안 #1008708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008708 2024-06-26T16:52:54 Z aaaaaarroz 참나무 (IOI23_beechtree) C++17
컴파일 오류
0 ms 0 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>padre;
vector<vector<int>>graph;
vector<int>sub;
void dfs(int nodo){
	sub.push_back(nodo);
	for(int vecino:graph[nodo]){
		dfs(vecino);
	}
}
vector<int> beechtree(int n, int m, vector<int>P, vector<int>C){
	padre=P;
	graph.resize(n,vector<int>());
	for(int i=1;i<n;i++){
		graph[P[i]].push_back(i);
	}
	vector<int>ans(n,0);
	for(int i=0;i<n;i++){
		sub.clear();
		dfs(i);
		if(sub.size()==1){
			ans[i]=1;
			continue;
		}
		sort(perm.begin()+1, perm.end());
		do{
			bool bien=true;
			map<int,int>repeticiones;
			for(int j=1;j<sub.size();j++){
				 if(repeticiones.find(C[sub[j]])==repeticiones.end()){
					repeticiones[C[sub[j]]]=0;
				 }
				if(repeticiones[C[sub[j]]]!=P[sub[j]]){
					bien=false;
					break;
				}
				repeticiones[C[sub[j]]]++;
			}
			if(bien){
				ans[i]=1;
				break;
			}
		}while(next_permutation(sub.begin()+1,sub.end()));
	}
	return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:27:8: error: 'perm' was not declared in this scope
   27 |   sort(perm.begin()+1, perm.end());
      |        ^~~~
beechtree.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for(int j=1;j<sub.size();j++){
      |                ~^~~~~~~~~~~