Submission #1028234

#TimeUsernameProblemLanguageResultExecution timeMemory
102823442kangarooThousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h" #include <variant> #include <vector> #include "bits/stdc++.h" using namespace std; using g_t = vector<vector<pair<int,int>>>; int dfs(int n, int d, int p, g_t& g, vector<bool>& vis, vector<int>& re) { vis[n] = true; for (auto [ne, nu]: g[n]) { if (vis[ne]) { re.push_back(nu); return ne; } int res = dfs(ne, nu, g, vis, re); if (re.empty()) continue; re.push_back(nu); if (res == n) { re.push_back(-1); return -2; } return res; } return -2; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { if (N == 2) { vector<int> s0, s1; for (int i = 0; i < M; ++i) { if (U[i] == 0) s0.push_back(i); else s1.push_back(i); } if (s0.size() >= 2 && s1.size() >= 1) { return vector<int>{s0[0], s1[0], s0[1], s0[0], s1[0], s0[1]}; } else return false; } g_t g(N); int s01, s10, s21, s02; for (int i = 0; i < M; ++i) { if (U[i] == 0 && V[i] == 1) s01 = i; if (U[i] == 1 && V[i] == 0) s10 = i; if (U[i] == 2 && V[i] == 1) s21 = i; if (U[i] == 0 && V[i] == 2) s02 = i; } return vector<int>{s02, s21, s10, s01, s21, s02, s10, s01}; }

Compilation message (stderr)

islands.cpp: In function 'int dfs(int, int, int, g_t&, std::vector<bool>&, std::vector<int>&)':
islands.cpp:18:25: error: cannot convert 'g_t' {aka 'std::vector<std::vector<std::pair<int, int> > >'} to 'int'
   18 |   int res = dfs(ne, nu, g, vis, re);
      |                         ^
      |                         |
      |                         g_t {aka std::vector<std::vector<std::pair<int, int> > >}
islands.cpp:11:27: note:   initializing argument 3 of 'int dfs(int, int, int, g_t&, std::vector<bool>&, std::vector<int>&)'
   11 | int dfs(int n, int d, int p, g_t& g, vector<bool>& vis, vector<int>& re) {
      |                       ~~~~^