답안 #963452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963452 2024-04-15T03:42:25 Z Namkhing 수천개의 섬 (IOI22_islands) C++17
컴파일 오류
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: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>