Submission #963451

# Submission time Handle Problem Language Result Execution time Memory
963451 2024-04-15T03:41:19 Z Namkhing Thousands Islands (IOI22_islands) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "islands.h"
using namespace std;

variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
    int first = 0, second = 0;

    for (int u : U) {
        if (u) {
            second++;
        }
        else {
            first++;
        }
    }

    if (first < 2 || second < 1) {
        return false;
    }

    int a, b, c;

    for (int i = 0; i < m; i++) {
        if (!U[i]) {
            a = i;
            break;
        }
    }

    for (int i = m - 1; i >= 0; i--) {
        if (!U[i]) {
            b = i;
            break;
        }
    }

    for (int i = 0; i < m; i++) {
        if (U[i]) {
            c = i;
            break;
        }
    }

    return {a, c, b, a, c, b};
}

Compilation message

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:23:25: error: 'm' was not declared in this scope
   23 |     for (int i = 0; i < m; i++) {
      |                         ^
islands.cpp:30:18: error: 'm' was not declared in this scope
   30 |     for (int i = m - 1; i >= 0; i--) {
      |                  ^
islands.cpp:37:25: error: 'm' was not declared in this scope
   37 |     for (int i = 0; i < m; i++) {
      |                         ^
islands.cpp:44:29: error: could not convert '{a, c, b, a, c, b}' from '<brace-enclosed initializer list>' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   44 |     return {a, c, b, a, c, b};
      |                             ^
      |                             |
      |                             <brace-enclosed initializer list>