Submission #813593

#TimeUsernameProblemLanguageResultExecution timeMemory
813593LiudasGame (IOI14_game)C++17
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; static const int buf_size = 4096; vector<set<int>> tree; int s; void initialize(int N){ tree.assign(N, vector<int>()); s = N; for(int i = 0; i < N; i ++){ for(int j = i + 1; j < N; j ++){ tree[i].insert(j); tree[j].insert(i); } } } void dfs(int head, vector<vector<int>> &tree, vector<bool> &vis, int &c){ c ++; vis[head] = true; for(int i : tree[head]){ if(!vis[i]){ dfs(i, tree, vis, c); } } } int hasEdge(int u, int v){ tree[u].erase(v); tree[v].erase(u); vector<bool> vis(s, false); int c = 0; dfs(0, tree, vis, c); if(c == s){ return 0; } else{ tree[u].insert(v); tree[v].insert(u); return 1; } }

Compilation message (stderr)

game.cpp: In function 'void initialize(int)':
game.cpp:8:33: error: no matching function for call to 'std::vector<std::set<int> >::assign(int&, std::vector<int>)'
    8 |     tree.assign(N, vector<int>());
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::set<int>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const std::set<int>&'}
  749 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
game.cpp:8:33: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
    8 |     tree.assign(N, vector<int>());
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:7: note:   candidate expects 1 argument, 2 provided
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:31:12: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'std::vector<std::set<int> >'
   31 |     dfs(0, tree, vis, c);
      |            ^~~~
game.cpp:17:41: note: in passing argument 2 of 'void dfs(int, std::vector<std::vector<int> >&, std::vector<bool>&, int&)'
   17 | void dfs(int head, vector<vector<int>> &tree, vector<bool> &vis, int &c){
      |                    ~~~~~~~~~~~~~~~~~~~~~^~~~