game.cpp:4:2: error: 'vector' does not name a type
vector<int> data;
^
game.cpp: In member function 'void UnionFind::init(int)':
game.cpp:6:21: error: 'data' was not declared in this scope
void init(int n) { data.assign(n, -1), compcnt=n; }
^
game.cpp: In member function 'bool UnionFind::unionSet(int, int)':
game.cpp:10:8: error: 'data' was not declared in this scope
if (data[y] < data[x]) swap(x, y);
^
game.cpp:10:36: error: 'swap' was not declared in this scope
if (data[y] < data[x]) swap(x, y);
^
game.cpp:10:36: note: suggested alternatives:
In file included from /usr/include/c++/5/complex:45:0,
from /usr/include/c++/5/ccomplex:38,
from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
from game.cpp:2:
/usr/include/c++/5/sstream:783:5: note: 'std::__cxx11::swap'
swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
^
In file included from /usr/include/c++/5/regex:61:0,
from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:108,
from game.cpp:2:
/usr/include/c++/5/bits/regex.h:1952:5: note: 'std::__cxx11::swap'
swap(match_results<_Bi_iter, _Alloc>& __lhs,
^
In file included from /usr/include/c++/5/exception:162:0,
from /usr/include/c++/5/ios:39,
from /usr/include/c++/5/istream:38,
from /usr/include/c++/5/sstream:38,
from /usr/include/c++/5/complex:45,
from /usr/include/c++/5/ccomplex:38,
from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
from game.cpp:2:
/usr/include/c++/5/bits/exception_ptr.h:160:5: note: 'std::__exception_ptr::swap'
swap(exception_ptr& __lhs, exception_ptr& __rhs)
^
game.cpp:11:4: error: 'data' was not declared in this scope
data[x] += data[y]; data[y] = x;
^
game.cpp: In member function 'int UnionFind::root(int)':
game.cpp:17:27: error: 'data' was not declared in this scope
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
^
game.cpp: In member function 'int UnionFind::size(int)':
game.cpp:18:28: error: 'data' was not declared in this scope
int size(int x) { return -data[root(x)]; }
^