Submission #1183533

#TimeUsernameProblemLanguageResultExecution timeMemory
1183533PagodePaivaThousands Islands (IOI22_islands)C++20
Compilation error
0 ms0 KiB
#include "islands.h" #include<bits/stdc++.h> #include <variant> #include <vector> using namespace std; const int N = 1010; const int M = 200010; vector <int> g[N]; int mark[M]; int mark_ver[N]; bool res = false; void dfs(int v, int p, int idx){ mark_ver[v] = 1; mark[idx] = 1; for(auto [x, i] : g[v]){ if(mark_ver[x] == 1 and mark[i] == 0){ res = true; return; } if(x == p) continue; dfs(x, v, i); } return; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { for(int i = 0;i < M;i++){ g[U[i]].push_back({V[i], i/2}); } vector <int> ans = {}; if(g[0].size() >= 2){ return ans; } dfs(0, 0, M-1); if(res) return ans; return res; }

Compilation message (stderr)

islands.cpp: In function 'void dfs(int, int, int)':
islands.cpp:17:14: error: cannot decompose non-array non-class type 'int'
   17 |     for(auto [x, i] : g[v]){
      |              ^~~~~~
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:32:26: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   32 |         g[U[i]].push_back({V[i], i/2});
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~