Submission #949963

#TimeUsernameProblemLanguageResultExecution timeMemory
949963irmuunConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include "supertrees.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() struct dsu{ int n; vector<int>sz,par; dsu(int n):n(n){ sz.resize(n); par.resize(n); fill(all(sz),1); iota(all(par),0); } int find(int x){ if(par[x]==x) return x; return par[x]=find(par[x]); } void merge(int x,int y){ x=find(x); y=find(y); if(x!=y){ if(sz[x]<sz[y]){ swap(x,y); } sz[x]+=sz[y]; par[y]=x; } } }; int construct(vector<vector<int>>p){ int n=p.size(); bool a[4]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ a[p[i][j]]=true; } } vector<vector<int>>b(n,vector<int>(n,0)); if(!a[2]&&!a[3]){ vector<bool>used(n,0); vector<int>ver; for(int i=0;i<n;i++){ if(!used[i]){ queue<int>q; q.push(i); used[i]=true; while(!q.empty()){ int x=q.front(); ver.pb(x); q.pop(); for(int j=0;j<n;j++){ if(p[x][j]==1&&!used[j]){ used[j]=true; q.push(j); } } } for(auto x:ver){ for(auto y:ver){ if(x!=y&&p[x][y]!=1){ return 0; } } } for(int j=1;j<ver.size();j++){ b[ver[j]][ver[j-1]]=1; b[ver[j-1]][ver[j]]=1; } ver.clear(); } } build(b); return 1; } if(a[0]&&!a[1]&&a[2]&&!a[3]){ vector<bool>used(n,0); vector<int>ver; for(int i=0;i<n;i++){ if(!used[i]){ queue<int>q; q.push(i); used[i]=true; while(!q.empty()){ int x=q.front(); ver.pb(x); q.pop(); for(int j=0;j<n;j++){ if(p[x][j]==2&&!used[j]){ used[j]=true; q.push(j); } } } for(auto x:ver){ for(auto y:ver){ if(x!=y&&p[x][y]!=2){ return 0; } } } for(int j=1;j<ver.size();j++){ b[ver[j]][ver[j-1]]=1; b[ver[j-1]][ver[j]]=1; } if(ver.size()>1){ b[ver[0]][ver.back()]=1; b[ver.back()][ver[0]]=1; } ver.clear(); } } build(b); return 1; } return 0; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:74:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |                 for(int j=1;j<ver.size();j++){
      |                             ~^~~~~~~~~~~
supertrees.cpp:81:9: error: 'build' was not declared in this scope
   81 |         build(b);
      |         ^~~~~
supertrees.cpp:110:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |                 for(int j=1;j<ver.size();j++){
      |                             ~^~~~~~~~~~~
supertrees.cpp:121:9: error: 'build' was not declared in this scope
  121 |         build(b);
      |         ^~~~~