Submission #305694

#TimeUsernameProblemLanguageResultExecution timeMemory
305694a_playerConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

const int nax=1e3+3;
int alt[nax];
int link[nax];
int find(int a){
	if(link[a]==a)return a;
	return link[a]=find(link[a]);
}
void unite(int a,int b){
	int x=find(a);
	int y=find(b);
	if(x==y)return;
	if(alt[x]>alt[y])link[y]=x;
	else{
		link[x]=y;
		if(alt[x]==alt[y])alt[y]++;
	}
}
bool same(int a, int b){
	return find(a)==find(b);
}
int construct(std::vector<std::vector<int>> p){
	int n=p.size();
	vector<vector<int>> b(n,vector<int>(n));
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++){
		if(p[i][j]==0&&same(i,j))return 0;#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

const int nax=1e3+3;
int alt[nax];
int link[nax];
int find(int a){
	if(link[a]==a)return a;
	return link[a]=find(link[a]);
}
void unite(int a,int b){
	int x=find(a);
	int y=find(b);
	if(x==y)return;
	if(alt[x]>alt[y])link[y]=x;
	else{
		link[x]=y;
		if(alt[x]==alt[y])alt[y]++;
	}
}
bool same(int a, int b){
	return find(a)==find(b);
}
int construct(std::vector<std::vector<int>> p){
	int n=p.size();
	vector<vector<int>> b(n,vector<int>(n));
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++){
		if(p[i][j]==1&&!same(i,j)){
			unite(i,j);
			b[i][j]=1;
			b[j][i]=1;
	}
}
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)if(same(i,j)&&p[i][j]==0)return 0;
build(b);
	return 1;
}

Compilation message (stderr)

supertrees.cpp:31:37: error: stray '#' in program
   31 |   if(p[i][j]==0&&same(i,j))return 0;#include "supertrees.h"
      |                                     ^
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:31:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |   if(p[i][j]==0&&same(i,j))return 0;#include "supertrees.h"
      |   ^~
supertrees.cpp:31:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |   if(p[i][j]==0&&same(i,j))return 0;#include "supertrees.h"
      |                                      ^~~~~~~
supertrees.cpp:31:38: error: 'include' was not declared in this scope
supertrees.cpp:39:16: error: a function-definition is not allowed here before '{' token
   39 | int find(int a){
      |                ^
supertrees.cpp:43:24: error: a function-definition is not allowed here before '{' token
   43 | void unite(int a,int b){
      |                        ^
supertrees.cpp:53:24: error: a function-definition is not allowed here before '{' token
   53 | bool same(int a, int b){
      |                        ^
supertrees.cpp:56:47: error: a function-definition is not allowed here before '{' token
   56 | int construct(std::vector<std::vector<int>> p){
      |                                               ^
supertrees.cpp:71:1: error: expected '}' at end of input
   71 | }
      | ^
supertrees.cpp:30:24: note: to match this '{'
   30 |  for(int j=i+1;j<n;j++){
      |                        ^
supertrees.cpp:37:5: warning: unused variable 'alt' [-Wunused-variable]
   37 | int alt[nax];
      |     ^~~
supertrees.cpp:38:5: warning: unused variable 'link' [-Wunused-variable]
   38 | int link[nax];
      |     ^~~~
supertrees.cpp:71:1: error: expected '}' at end of input
   71 | }
      | ^
supertrees.cpp:26:47: note: to match this '{'
   26 | int construct(std::vector<std::vector<int>> p){
      |                                               ^
supertrees.cpp:28:40: warning: control reaches end of non-void function [-Wreturn-type]
   28 |  vector<vector<int>> b(n,vector<int>(n));
      |                                        ^