Submission #944506

#TimeUsernameProblemLanguageResultExecution timeMemory
9445064QT0RGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n; int lider[1503]; int siz[1503]; int zap[1503][1503]; void initialize(int rozmiar){ n=rozmiar; for (int i = 0; i<n; i++){ lider[i]=i; siz[i]=1; } } int Find(int v){ if (lider[v]==v)return v; lider[v]=Find(lider[v]); return lider[v]; } void Union(int a, int b){ a=Find(a); b=Find(b); if (a==b)return; if (siz[a]<siz[b])swap(a,b); lider[b]=a; siz[a]+=siz[b]; for (int i = 0; i<n; i++){ if (i==a)continue; zap[a][i]+=zap[b][i]; zap[i][a]+=zap[i][b]; } } int hasEdge(int u, int v){ u=Find(u); v=Find(v); if (u==v)return 0; zap[v][u]++; zap[u][v]++; else if (siz[v]*siz[u]>zap[v][u])return 0; else{ Union(u,v); return 1; } }

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:43:2: error: 'else' without a previous 'if'
   43 |  else if (siz[v]*siz[u]>zap[v][u])return 0;
      |  ^~~~