답안 #1008700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008700 2024-06-26T16:47:45 Z aaaaaarroz 참나무 (IOI23_beechtree) C++17
0 / 100
2000 ms 348 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;
	for(int i=0;i<n;i++){
		sub.clear();
		dfs(i);
		if(sub.size()==1){
			ans.push_back(1);
			continue;
		}
		bool posible=false;
		do{
			bool bien=true;
			map<int,int>repeticiones;
			for(int i=1;i<sub.size();i++){
				 if(repeticiones.find(C[sub[i]])==repeticiones.end()){
					repeticiones[C[sub[i]]]=0;
				 }
				if(repeticiones[C[sub[i]]]!=P[sub[i]]){
					bien=false;
					break;
				}
				repeticiones[C[sub[i]]]++;
			}
			posible|=bien;
		}while(next_permutation(sub.begin()+1,sub.end()));
		ans.push_back((posible==true?1:0));
	}
	return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
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 i=1;i<sub.size();i++){
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2090 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2039 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2090 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2090 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 2090 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -