Submission #375624

#TimeUsernameProblemLanguageResultExecution timeMemory
375624Alex_tz307Game (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> const int NMAX = 1505; int N, p[NMAX], sz[NMAX], cnt[NMAX][NMAX]; int get(int x) { if(x == p[x]) return x; return p[x] = get(p[x]); } void unite(int u, int v) { if(sz[u] < sz[v]) swap(u, v); for(int k = 1; k <= N; ++k) cnt[u][k] += cnt[v][k], cnt[k][u] += cnt[v][k]; p[v] = u; } void initialize(int n) { N = n; for(int i = 1; i <= N; ++i) { p[i] = i; sz[i] = 1; for(int j = 1; j <= N; ++j) if(i != j) cnt[i][j] = 1; } } int hasEdge(int u, int v) { ++u, ++v; u = get(u); v = get(v); if(u == v) return 0; if(cnt[u][v] > 1) { --cnt[u][v], --cnt[v][u]; return 0; } unite(x, y); return 1; }

Compilation message (stderr)

game.cpp: In function 'void unite(int, int)':
game.cpp:14:9: error: 'swap' was not declared in this scope
   14 |         swap(u, v);
      |         ^~~~
game.cpp:14:9: note: suggested alternatives:
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from game.cpp:1:
/usr/include/c++/9/bits/regex.h:2029:5: note:   'std::__cxx11::swap'
 2029 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/9/bits/stl_pair.h:59,
                 from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from game.cpp:1:
/usr/include/c++/9/bits/move.h:182:5: note:   'std::swap'
  182 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/9/bits/move.h:182:5: note:   'std::swap'
In file included from /usr/include/c++/9/exception:143,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from game.cpp:1:
/usr/include/c++/9/bits/exception_ptr.h:166:5: note:   'std::__exception_ptr::swap'
  166 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/9/filesystem:37,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:129,
                 from game.cpp:1:
/usr/include/c++/9/bits/fs_path.h:611:15: note:   'std::filesystem::__cxx11::swap'
  611 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:41:11: error: 'x' was not declared in this scope
   41 |     unite(x, y);
      |           ^
game.cpp:41:14: error: 'y' was not declared in this scope
   41 |     unite(x, y);
      |              ^