Submission #1137288

#TimeUsernameProblemLanguageResultExecution timeMemory
1137288viwlesxqGame (IOI14_game)C++20
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; struct DSU { int n; vector<int> p; vector<vector<int>> st; void xxx(int n) { this->n = n; p.resize(n); st.resize(n); for (int i = 0; i < n; ++i) { p[i] = i; st.push_back(i); } } int find_set(int v) { return v == p[v] ? v : p[v] = find_set(p[v]); } void unite(int u, int v) { u = find_set(u); v = find_set(v); if (u == v) return; if (st[u].size() > st[v].size()) swap(u, v); p[u] = v; for (auto i : st[u]) { st[v].push_back(i); } st[u].clear(); } }; DSU g; bool used[1500][1500]; void initialize(int n) { g.xxx(n); } int hasEdge(int U, int V) { int u = g.find_set(U); int v = g.find_set(V); bool flag = true; for (auto a : st[u]) { for (auto b : st[v]) { if (!used[a][b]) { flag = false; break; } } } used[U][V] = used[V][U] = true; if (flag) { g.unite(u, v); return 1; } else { return 0; } }

Compilation message (stderr)

game.cpp: In member function 'void DSU::xxx(int)':
game.cpp:18:25: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int&)'
   18 |             st.push_back(i);
      |             ~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::vector<int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:56:19: error: 'st' was not declared in this scope; did you mean 'std'?
   56 |     for (auto a : st[u]) {
      |                   ^~
      |                   std