Submission #310354

#TimeUsernameProblemLanguageResultExecution timeMemory
310354APROHACK슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
3 ms512 KiB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
long long padres[1200];
long long fnd(long long nodo){
    if(padres[nodo]==nodo)return nodo;
    else padres[nodo]=fnd(padres[nodo]);
}
int construct(vector<vector<int> >p) {
	int n = p.size();
    vector<vector<int> > answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		for(int j = 0 ; j < n ; j ++)row[j]=0;
		answer.push_back(row);
		padres[i]= i;
	}
	for(int i = 0 ; i < n-1 ; i ++){
        for(int j= i +1 ; j < n ; j ++){
            if(p[i][j]==1){
                padres[fnd(i)]=fnd(j);
            }
        }
	}
	for(int i = 0 ; i < n-1 ; i ++){
        for(int j= i +1 ; j < n ; j ++){
            if(p[i][j]==0){
                if(fnd(i)==fnd(j))return 0;
            }
        }
	}
	for(int i = 0 ; i < n ; i ++){
        if(fnd(i)==i)continue;
        else {
            answer[padres[i]][i]=1;
            answer[i][padres[i]]=1;
        }
	}


	build(answer);
	return 1;
}

Compilation message (stderr)

supertrees.cpp: In function 'long long int fnd(long long int)':
supertrees.cpp:7:22: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     else padres[nodo]=fnd(padres[nodo]);
      |          ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...