Submission #349200

#TimeUsernameProblemLanguageResultExecution timeMemory
349200justiny7Connecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define eb emplace_back #define go(x) if (x(p)) { build(ans); return 1; } return 0 using namespace std; using vi=vector<int>; using vvi=vector<vi>; const int mxN=1e3+1; int n; vvi ans; struct DSU { int par[mxN], sz[mxN]; DSU(int n) { for (int i=0; i<n; ++i) par[i]=i, sz[i]=1; } int find(int v) { return (par[v]==v?v:par[v]=find(par[v])); } bool merge(int a, int b) { a=find(a), b=find(b); if (a==b) return 0; if (sz[a]>sz[b]) swap(a, b); par[a]=b, sz[b]+=sz[a]; return 1; } bool same(int a, int b) { return (find(a)==find(b)); } }; bool subtask_3(vvi &p) { DSU d(n); bool f=0; for (int i=0; i<n; ++i) for (int j=0; j<n; ++j) if (p[i][j]) d.merge(i, j), f|=(p[i][j]==2); for (int i=0; i<n; ++i) for (int j=0; j<n; ++j) if (!p[i][j] && d.same(i, j)) return 0; vector<bool> vis(n); for (int i=0; i<n; ++i) { if (vis[d.find(i)]) continue; vis[d.find(i)]=1; vi v; for (int j=0; j<n; ++j) if (d.same(i, j)) v.eb(j); int sz=v.size(); for (int j=0; j<sz; ++j) { if (j) ans[v[j]][v[j-1]]=ans[v[j-1]][v[j]]=1; if (j<sz-1) ans[v[j]][v[j+1]]=ans[v[j+1]][v[j]]=1; } if (f) { if (sz>2) ans[v[0]][v.back()]=ans[v.back()][v[0]]=1; else if (sz==2) return 0; } } return 1; } bool subtask_4(vvi &p) { ; } int construct(vvi p) { n=p.size(); ans=vvi(n, vi(n)); bool f0=0, f1=0, f2=0, f3=0; for (int i=0; i<n; ++i) { for (int j=0; j<n; ++j) { if (i==j) continue; f0|=(!p[i][j]); f1|=(p[i][j]==1); f2|=(p[i][j]==2); f3|=(p[i][j]==3); } } if (!f3) { if (!(f1 && f2)) go(subtask_3); else go(subtask_4); } else { ; } }

Compilation message (stderr)

supertrees.cpp: In function 'bool subtask_4(vvi&)':
supertrees.cpp:74:1: warning: no return statement in function returning non-void [-Wreturn-type]
   74 | }
      | ^
supertrees.cpp: In function 'int construct(vvi)':
supertrees.cpp:93:9: error: expected '}' before 'else'
   93 |         else
      |         ^~~~
supertrees.cpp:90:14: note: to match this '{'
   90 |     if (!f3) {
      |              ^
supertrees.cpp: At global scope:
supertrees.cpp:96:5: error: expected unqualified-id before 'else'
   96 |     else {
      |     ^~~~
supertrees.cpp:99:1: error: expected declaration before '}' token
   99 | }
      | ^