Submission #440972

#TimeUsernameProblemLanguageResultExecution timeMemory
440972julian33Game (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} const int mxN=15e2+5; int uf[mxN],num,cnt[mxN]; int find(int x){return uf[x]<0?x:uf[x]=find(uf[x]);} bool same(int x,int y){return find(x)==find(y);} void unite(int x,int y){ x=find(x); y=find(y); if(x==y) return if(uf[x]>uf[y]) swap(x,y); uf[x]+=uf[y]; uf[y]=x; num--; } int hasEdge(int u,int v){ if(num==2) return 0; cnt[u]++; cnt[v]++; if(same(u,v)) return 0; if(cnt[u]==n-1 || cnt[v]==n-1) return 1; return 0; } void initialize(int n){ memset(uf,-1,sizeof(uf)); num=n; }

Compilation message (stderr)

game.cpp: In function 'void unite(int, int)':
game.cpp:38:5: error: expected primary-expression before 'if'
   38 |     if(uf[x]>uf[y])
      |     ^~
game.cpp:37:15: error: expected ';' before 'if'
   37 |         return
      |               ^
      |               ;
   38 |     if(uf[x]>uf[y])
      |     ~~         
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:50:16: error: 'n' was not declared in this scope
   50 |     if(cnt[u]==n-1 || cnt[v]==n-1)
      |                ^