Submission #672634

#TimeUsernameProblemLanguageResultExecution timeMemory
672634blueGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; int n; struct dsu { vi par; vi st; dsu() { par = vi(1500, -1); st = vi(1500, 1); for(int i = 0; i < 1500; i++) par[i] = i; } int root(int u) { if(par[u] == u) return u; else return (par[u] = root(par[u])); } void join(int u, int v) { u = root(u); v = root(v); if(u == v) return; if(st[u] < st[v]) swap(u, v); par[v] = u; st[u] += st[v]; } } dsu ds; int comp; void initialize(int n_) { n = n_; comp = n; } int hasEdge(int u, int v) { if(ds.root(u) == ds.root(v)) return 1; else if(comp == 2) return 0; else { ds.join(u, v); return 1; } }

Compilation message (stderr)

game.cpp:47:5: error: expected initializer before 'ds'
   47 | dsu ds;
      |     ^~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:58:6: error: 'ds' was not declared in this scope; did you mean 'dsu'?
   58 |   if(ds.root(u) == ds.root(v))
      |      ^~
      |      dsu
game.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
   67 | }
      | ^