Submission #776283

#TimeUsernameProblemLanguageResultExecution timeMemory
776283benjaminkleynGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include "game.h"
#include <bits/stdc++.h>

int e[1500];
int find(int u)
{
    return e[u] < 0 ? u : e[u] = find(e[u]);
}
bool unite(int u, int v)
{
    u = find(u), v = find(v);
    if (u == v) return false;
    if (e[u] > e[v]) swap(u, v);
    e[u] += e[v], e[v] = u;
    return true;
}
void initialize(int n)
{
    for (int i = 0; i < n; i++)
        e[i] = -1;
}
int hasEdge(int u, int v)
{
    return unite(u, v);
}

Compilation message (stderr)

game.cpp: In function 'bool unite(int, int)':
game.cpp:13:22: error: 'swap' was not declared in this scope
   13 |     if (e[u] > e[v]) swap(u, v);
      |                      ^~~~
game.cpp:13:22: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from game.cpp:2:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from game.cpp:2:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from game.cpp:2:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/filesystem:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from game.cpp:2:
/usr/include/c++/10/bits/fs_path.h:658:15: note:   'std::filesystem::__cxx11::swap'
  658 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~