제출 #628875

#제출 시각아이디문제언어결과실행 시간메모리
628875welleyth수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <variant> #include <vector> #include <bits/stdc++.h> using namespace std; map<pair<int,int>,vector<int>> cnt; vector<int> ans; bool ok = true; void go1(int a,int b){ pair<int,int> A = {a,b}; pair<int,int> B = {b,a}; if(cnt[A].size() == 0){ ok = false; return; } ans.push_back(cnt[A][0]); return; } void go2(int a,int b){ pair<int,int> A = {a,b}; pair<int,int> B = {b,a}; if(cnt[B].size() == 0){ ok = false; return; } ans.push_back(cnt[B][0]); if(cnt[A].size() < 2){ ok = false; return; } ans.push_back(cnt[A][1]); ans.push_back(cnt[A][0]); ans.push_back(cnt[B][0]); ans.push_back(cnt[A][1]); return; } std::variant<bool, std::vector<int>> find_journey( return true; int N, int M, std::vector<int> U, std::vector<int> V) { for(int i = 0; i < M; i++){ cnt[{U[i],V[i]}].push_back(i); } for(int i = 0; i + 1 < N; i++){ go1(i,i+1); } for(int i = N-2; i >= 0; i--){ go2(i,i+1); if(!ok) return false; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

islands.cpp: In function 'void go1(int, int)':
islands.cpp:13:19: warning: variable 'B' set but not used [-Wunused-but-set-variable]
   13 |     pair<int,int> B = {b,a};
      |                   ^
islands.cpp: At global scope:
islands.cpp:40:50: error: 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey' redeclared as different kind of entity
   40 | std::variant<bool, std::vector<int>> find_journey(
      |                                                  ^
In file included from islands.cpp:1:
islands.h:4:38: note: previous declaration 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)'
    4 | std::variant<bool, std::vector<int>> find_journey(
      |                                      ^~~~~~~~~~~~
islands.cpp:41:5: error: expected primary-expression before 'return'
   41 |     return true;
      |     ^~~~~~
islands.cpp:42:12: error: expected unqualified-id before 'int'
   42 |     int N, int M, std::vector<int> U, std::vector<int> V) {
      |            ^~~