제출 #963452

#제출 시각아이디문제언어결과실행 시간메모리
963452Namkhing수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#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};
}

컴파일 시 표준 에러 (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: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>