Submission #742558

# Submission time Handle Problem Language Result Execution time Memory
742558 2023-05-16T13:00:41 Z keisuke6 Game (APIO22_game) C++17
Compilation error
0 ms 0 KB
#include "game.h"
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;

vector<vector<unordered_set<int>>> G(1001,vector<unordered_set<int>>(30010));
vector<vector<bool>> P(1001,vector<bool>(30010,false));
int N,K;
void init(int n, int k) {
  N = n;
  K = k;
  for(int i=0;i<k;i++)for(int j=i;j<k;j++) P[i][j] = true;
}

int add_teleporter(int u, int v) {
  for(int i=0;i<K;i++){
    G[u].insert(v);
    if(!P[u]){
      continue;
    }
    queue<int> q;
    q.push(u);
    while(!q.empty()){
      int pos = q.front();
      q.pop();
      for(int x:G[pos]){
        G[pos].erase(x);
        if(P[x]){
          if(x <= i) return 1;
          continue;
        }
        P[x] = true;
        q.push(x);
      }
    }
  }
  return false;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:19:18: error: no matching function for call to 'std::vector<std::unordered_set<int> >::insert(int&)'
   19 |     G[u].insert(v);
      |                  ^
In file included from /usr/include/c++/10/vector:72,
                 from game.cpp:3:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator; std::vector<_Tp, _Alloc>::value_type = std::unordered_set<int>]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:130:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/10/vector:67,
                 from game.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator; std::vector<_Tp, _Alloc>::value_type = std::unordered_set<int>]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::unordered_set<int>]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
game.cpp:19:18: note:   candidate expects 3 arguments, 1 provided
   19 |     G[u].insert(v);
      |                  ^
game.cpp:20:8: error: no match for 'operator!' (operand type is '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'})
   20 |     if(!P[u]){
game.cpp:20:8: note: candidate: 'operator!(bool)' (built-in)
game.cpp:20:8: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} to 'bool'
game.cpp:28:22: error: cannot convert 'std::unordered_set<int>' to 'int' in initialization
   28 |       for(int x:G[pos]){
      |                      ^
game.cpp:29:23: error: no matching function for call to 'std::vector<std::unordered_set<int> >::erase(int&)'
   29 |         G[pos].erase(x);
      |                       ^
In file included from /usr/include/c++/10/vector:67,
                 from game.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::unordered_set<int> >::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = std::unordered_set<int>; _Alloc = std::allocator<std::unordered_set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::unordered_set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::unordered_set<int> >::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
game.cpp:30:16: error: could not convert 'P.std::vector<std::vector<bool> >::operator[](((std::vector<std::vector<bool> >::size_type)x))' from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} to 'bool'
   30 |         if(P[x]){
      |                ^
      |                |
      |                __gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type {aka std::vector<bool>}
game.cpp:34:16: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} and 'bool')
   34 |         P[x] = true;
      |                ^~~~
In file included from /usr/include/c++/10/vector:68,
                 from game.cpp:3:
/usr/include/c++/10/bits/stl_bvector.h:740:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  740 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:740:31: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<bool>&'
  740 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_bvector.h:771:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  771 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:771:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<bool>&&'
  771 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_bvector.h:796:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  796 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:796:40: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<bool>'
  796 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~