Submission #1292642

#TimeUsernameProblemLanguageResultExecution timeMemory
1292642alexrana2626World Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include "worldmap.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> gr[40];
vector<bool> vis[40];
void dfs(int x)
{
  vis[x] = true;
  v.push_back(x);
  for(auto i : gr[x])
  {
  	if (!vis[i])
  	{
  	    dfs(i);
	}
  }
}

vector<vector<int>> create_map(int N, int M, vector<int> A, vector<int> B) {

 
  vector<int> v;
  for (int i = 0; i < M; i++)
  {
  	gr[A[i]].push_back(B[i]);
  	gr[B[i]].push_back(A[i]);
  }
  dfs(1);
   vector<vector<int>> ans(v.size(), vector<int>(v.size(), 1));
  for (int i = 0; i < v.size(); i++)
  {
  	for (int j = 0; j < v.size(); j++)
  	{
  		ans[i][j] = v[i];
	}
  }
  return ans;
}

Compilation message (stderr)

worldmap.cpp: In function 'void dfs(int)':
worldmap.cpp:8:12: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'bool')
    8 |   vis[x] = true;
      |            ^~~~
In file included from /usr/include/c++/13/vector:67,
                 from worldmap.h:1,
                 from worldmap.cpp:1:
/usr/include/c++/13/bits/stl_bvector.h:894:7: note: candidate: 'constexpr std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  894 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_bvector.h:894:31: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<bool>&'
  894 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_bvector.h:926:7: note: candidate: 'constexpr std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  926 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_bvector.h:926:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<bool>&&'
  926 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_bvector.h:952:7: note: candidate: 'constexpr std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  952 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_bvector.h:952:40: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<bool>'
  952 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~
worldmap.cpp:9:3: error: 'v' was not declared in this scope
    9 |   v.push_back(x);
      |   ^
worldmap.cpp:12:13: error: no match for 'operator!' (operand type is 'std::vector<bool>')
   12 |         if (!vis[i])
      |             ^~~~~~~
worldmap.cpp:12:13: note: candidate: 'operator!(bool)' (built-in)
worldmap.cpp:12:13: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'bool'