#include <bits/stdc++.h>
using namespace std;
int perform_experiment(vector<int> E);
vector<int>alll(int n,vector<int> x,vector<int> y){
vector<int>color(n);
for(int i=0;i<n;i++){
vector<int>nodos;
for(int j=0;j<n;j++){
if(j!=i){
nodos.push_back(j);
}
}
int l=0,r=n-1;
while(l<r){
int mid=(l+r)/2;
vector<int>exp(n,l);
exp[i]=-1;
int node=0;
for(int j=l;j<=mid;j++){
exp[nodos[node]]=j;
node++;
}
int experimento=perform_experiment(exp);
if(experimento==(mid-l+1)){
r=mid;
}
else{
l=mid+1;
}
}
color[i]=l;
}
return color;
}
vector<int>uno(int n,vector<int> x,vector<int> y){
vector<int>color(n);
color[0]=0;
for(int i=1;i<n;i++){
vector<int>exp(n,n);
exp[i]=-1;
exp[i-1]=color[i-1];
if(perform_experiment(exp)==2){
if(color[i-1]==0){
color[i]=1;
}
else{
color[i]=0;
}
}
else{
color[i]=color[i-1];
}
}
return color;
}
vector<int> find_colours(int n,vector<int> x,vector<int> y){
vector<int>grado(n,0);
for(int i=0;i<n;i++){
grado[x[i]]++;
grado[y[i]]++;
}
bool all=true;
bool solo1=true;
for(int i=0;i<n;i++){
if(grado[i]!=(n-1)){
all=false;
}
if(grado[i]!=1){
solo1=false;
}
}
if(all){
return alll(n,x,y);
}
if(solo1){
return uno(n,x,y);
}
}
Compilation message (stderr)
sphinx.cpp: In function 'std::vector<int> find_colours(int, std::vector<int>, std::vector<int>)':
sphinx.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
78 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |