제출 #1315605

#제출 시각아이디문제언어결과실행 시간메모리
1315605PlayVoltz수천개의 섬 (IOI22_islands)C++20
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second variant<bool, vector<int> > find_journey(int n, int m, vector<int> u, vector<int> v){ if (m<3)break; vector<int> a, b; for (int i=0; i<m; ++i){ if (v[i])a.pb(i); else b.pb(i); } if (a.empty()||b.empty())return 0; if (a.size()>=2)return {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:17: error: break statement not within loop or switch
   12 |         if (m<3)break;
      |                 ^~~~~
islands.cpp:18:41: error: could not convert '0' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   18 |         if (a.empty()||b.empty())return 0;
      |                                         ^
      |                                         |
      |                                         int
islands.cpp:19:67: error: could not convert '{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> > >'
   19 |         if (a.size()>=2)return {a[0], b[0], a[1], a[0], b[0], a[1]};
      |                                                                   ^
      |                                                                   |
      |                                                                   <brace-enclosed initializer list>
islands.cpp:20:16: error: could not convert '0' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   20 |         return 0;
      |                ^
      |                |
      |                int