제출 #667022

#제출 시각아이디문제언어결과실행 시간메모리
667022mychecksedad수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <utility>
#include <variant>
using namespace std;
#define pb push_back

variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V){
    vector<int> a, b;
    for(int i = 0; i < M; ++i) if(U[i] == 0) a.pb(i); 
    for(int i = 0; i < M; ++i) if(U[i] == 1) b.pb(i);
    if(a.size() >= 2 && b.size() >= 1){
        return {1, {a[0], b[0], a[1], a[0], b[0], a[1]}};
    }   
    return {0, {}}; 
}

컴파일 시 표준 에러 (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:12:56: error: could not convert '{1, {a.std::vector<int>::operator[](0), b.std::vector<int>::operator[](0), a.std::vector<int>::operator[](1), a.std::vector<int>::operator[](0), b.std::vector<int>::operator[](0), a.std::vector<int>::operator[](1)}}' from '<brace-enclosed initializer list>' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   12 |         return {1, {a[0], b[0], a[1], a[0], b[0], a[1]}};
      |                                                        ^
      |                                                        |
      |                                                        <brace-enclosed initializer list>
islands.cpp:14:18: error: could not convert '{0, <brace-enclosed initializer list>()}' from '<brace-enclosed initializer list>' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   14 |     return {0, {}};
      |                  ^
      |                  |
      |                  <brace-enclosed initializer list>