Submission #302199

#TimeUsernameProblemLanguageResultExecution timeMemory
302199aymane7Connecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include"supertrees.h" #pragma GCC optimize("O2") #define S second #define F first #define PB push_back #define sz(x) (int) x.size() #define all(x) x.begin(),x.end() #define L(x) 2*x #define R(x) 2*x+1 #define M(x,y) (x+y)/2 using namespace std; typedef long long ll; const int N=1e3+1; int p[N],lvl[N]; int getp(int x){ return (p[x]==x)? x : p[x]=getp(p[x]); } void unite(int i,int j){ int x=getp(i),y=getp(j); if(x==y) return ; if(lvl[x]>lvl[y]) swap(x,y); p[x]=y; if(lvl[x]==lvl[y]) lvl[y]++; } void build(vector<vector<int>> t){ for(auto v:t){ for(auto x:v) cout<<x<<" "; cout<<endl; } } int construct(vector<vector<int>> b){ int n=sz(b); vector<vector<int>> ans(n,vector<int>(n,0)); for(int i=0;i<n;i++){ lvl[i]=0; p[i]=i; } int type=1; for(int i=0;i<n;i++) for(int j=0;j<n;j++){ if(b[i][j]==2) unite(i,j); } vector<int> co[n]; for(int i=0;i<n;i++) co[getp(i)].PB(i); for(int i=0;i<n;i++){ if(sz(co[i])<=1) continue; if(sz(co[i])==2){ return 0; } for(int j=0;j<sz(co[i])-1;j++) ans[co[i][j]][co[i][j+1]]=1,ans[co[i][j+1]][co[i][j]]=1; ans[co[i][0]][co[i].back()]=1,ans[co[i].back()][co[i][0]]=1; for(auto x:co[i]) for(auto y:co[i]){ if(x==y) continue; if(b[x][y]==0) return 0; } } build(ans); return 1; } int main(){ int n; cin>>n; vector<vector<int>> t(n,vector<int>(n,0)); for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>t[i][j]; construct(t); }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:43:9: warning: unused variable 'type' [-Wunused-variable]
   43 |     int type=1;
      |         ^~~~
/tmp/ccXquAsa.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccO7wZxd.o:supertrees.cpp:(.text.startup+0x0): first defined here
/tmp/ccXquAsa.o: In function `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x110): multiple definition of `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/tmp/ccO7wZxd.o:supertrees.cpp:(.text+0xc0): first defined here
collect2: error: ld returned 1 exit status