Submission #784390

#TimeUsernameProblemLanguageResultExecution timeMemory
784390qwerasdfzxclGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include "game.h"
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
int n; 

struct DSU{
  int path[1515], cnt[1515][1515];
  void init(int n){
    for (int i=1;i<=n;;i++){
      path[i] = i;
      for (int j=1;j<=n;j++) if (i!=j) cnt[i][j] = 1;
    }
  }
  
  int find(int s){
    if (s==path[s]) return s;
    return path[s] = find(path[s]);
  }
  
  int merge(int s, int v){
    s = find(s), v = find(v);
    assert(s!=v);
    if (cnt[s][v] > 1){
      cnt[s][v]--;
      cnt[v][s]--;
      return 0;
    }
    
    path[v] = s;
    for (int i=1;i<=n;i++) if (find(i)==i && i!=s){
      cnt[s][i] += cnt[v][i];
      cnt[i][s] = cnt[s][i];
    }
  }
}dsu;
 
void initialize(int N) {
  n = N;
  dsu.init(n);
}
 
int hasEdge(int u, int v) {
  ++u, ++v;
  return dsu.merge(u, v);
}

Compilation message (stderr)

game.cpp: In member function 'void DSU::init(int)':
game.cpp:11:23: error: expected primary-expression before ';' token
   11 |     for (int i=1;i<=n;;i++){
      |                       ^
game.cpp:11:23: error: expected ')' before ';' token
   11 |     for (int i=1;i<=n;;i++){
      |         ~             ^
      |                       )
game.cpp:11:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   11 |     for (int i=1;i<=n;;i++){
      |     ^~~
game.cpp:11:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   11 |     for (int i=1;i<=n;;i++){
      |                        ^
game.cpp:11:24: error: 'i' was not declared in this scope
game.cpp: In member function 'int DSU::merge(int, int)':
game.cpp:36:3: warning: control reaches end of non-void function [-Wreturn-type]
   36 |   }
      |   ^