Submission #1024693

#TimeUsernameProblemLanguageResultExecution timeMemory
1024693vjudge1Thousands Islands (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h"
#include <bits/stdc++.h>
#include <variant>

using namespace std;

#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int) s.size()
#define s second 
#define f first 

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int N = 3e5;

vector<pii> g[N], pr(N);
vector<int> was(N), s;
int is = 0;

void dfs(int u, int x) {
    was[u] = 1;
    for (auto [to, id]: g[u]) {
        if (id == x) continue;
        if (!was[to]) {
            pr[to] = {u, id};
            dfs(to, id);
            if (is) return;
        }else if (!to) {
            is = 1; 
            return;
            s.push_back(id);
            while (u) {
                s.push_back(pr[u].s);
                u = pr[u].f;
            }
            return;
        }
    }
}

variant<bool, vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v) {
    for (int i = 0; i < m; i++) g[u[i]].push_back({v[i], i});
    if (n == 2) {
        if (sz(g[0]) > 1 && sz(g[1])) {
            return {g[0][0].s, g[1][0].s, g[0][1].s, g[0][0].s, g[1][0].s, g[0][1].s};
        }
        return false;
    }
    int cnt = 0;
    for (auto [to, id]: g[0]) {
        dfs(to, id);
        if (is) cnt++;
    }
    return cnt > 1;
    reverse(all(s));
    vector<int> ans;
    for (int x: s) ans.push_back(x);

}

Compilation message (stderr)

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:48:85: error: could not convert '{g[0].std::vector<std::pair<int, int> >::operator[](0).std::pair<int, int>::second, g[1].std::vector<std::pair<int, int> >::operator[](0).std::pair<int, int>::second, g[0].std::vector<std::pair<int, int> >::operator[](1).std::pair<int, int>::second, g[0].std::vector<std::pair<int, int> >::operator[](0).std::pair<int, int>::second, g[1].std::vector<std::pair<int, int> >::operator[](0).std::pair<int, int>::second, g[0].std::vector<std::pair<int, int> >::operator[](1).std::pair<int, int>::second}' from '<brace-enclosed initializer list>' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   48 |             return {g[0][0].s, g[1][0].s, g[0][1].s, g[0][0].s, g[1][0].s, g[0][1].s};
      |                                                                                     ^
      |                                                                                     |
      |                                                                                     <brace-enclosed initializer list>