제출 #628524

#제출 시각아이디문제언어결과실행 시간메모리
628524Sorting수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <variant> #include <vector> #include <algorithm> #include <cmath> using namespace std; std::variant<bool, std::vector<int>> find_journey( int n, int m, std::vector<int> u, std::vector<int> v) { if(n == 2){ vector<int> cnt[2]{}; for(int i = 0; i < u.size();++i){ cnt[u[i]].push_back(i); } if(cnt[0].size() >= 2 && cnt[1].size() >= 1){ return vector<int>{cnt[0][0], cnt[1][0], cnt[0][1], cnt[0][0], cnt[1][0], cnt[0][1]}; } return false; } vector<vector<pair<int, int>>> adj(n); for(int i = 0; i < m; ++i) adj[u[i]].push_back({v[i], i}); int x = 1, par = -1; while(true){ if(adj[x].size() != 1 + (x != 1)){ if(adj[x].size() < 1 + (x != 1)){ return false; } return true; } for(auto p: adj[x]){ int to = p.first; int idx = p.second; if(to == par){ par = -1; continue; } par = x; x = to; } } assert(false); }

컴파일 시 표준 에러 (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:14:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int i = 0; i < u.size();++i){
      |                        ~~^~~~~~~~~~
islands.cpp:37:17: warning: unused variable 'idx' [-Wunused-variable]
   37 |             int idx = p.second;
      |                 ^~~
islands.cpp:46:5: error: 'assert' was not declared in this scope
   46 |     assert(false);
      |     ^~~~~~
islands.cpp:7:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    6 | #include <cmath>
  +++ |+#include <cassert>
    7 |