제출 #637464

#제출 시각아이디문제언어결과실행 시간메모리
637464Ozy수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i < = (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define lli long long int #define MAX 100000 #define des first #define id second int n,m; vector<pair<int,int> > hijos[MAX]; vector<int> res; bool solve(int pos,int padre) { lli cont = 0; pair<int,int> obj[2],regreso[2]; for (auto h : hijos[pos]){ if (h.des == padre) continue; obj[cont] = h; cont++; if (cont == 2) break; } //tomar en cuenta que puede ser la misma balsa y estar usada if (cont == 0) return false; if (cont == 1) { //caso en el cual sigues avanzando por ahi res.push_back(obj[0].id); if (solve(obj[0].des,pos) { res.push_back(obj[0].id); return true; } else { res.pop_back(); return false; } } //caso en el que tu empiezas a ser true for (auto h : hijos[obj[0].des]) { if (h.des == pos) { regreso[0] = {pos,h.id}; break; } } for (auto h : hijos[obj[1].des]) { if (h.des == pos && h != regreso[0]) { regreso[1] = {pos,h.id}; break; } } //pon la secuencia int a = obj[0].id; int b = regreso[0].id; int c = obj[1].id; int d = regreso[1].id; res.push_back(a); res.push_back(b); res.push_back(c); res.push_back(d); res.push_back(b); res.push_back(a); res.push_back(d); res.push_back(c); return true; } std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) { n = N; m = M; rep(i,0,m-1) hijos[U[i]].push_back(V[i],i); if (solve(0,-1)) return res; else return false; }

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

islands.cpp: In function 'bool solve(int, int)':
islands.cpp:37:34: error: expected ')' before '{' token
   37 |         if (solve(obj[0].des,pos) {
      |            ~                     ^~
      |                                  )
islands.cpp:45:5: error: expected primary-expression before '}' token
   45 |     }
      |     ^
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:4:42: error: expected primary-expression before '=' token
    4 | #define rep(i,a,b) for (int i = (a); i < = (b); i++)
      |                                          ^
islands.cpp:86:5: note: in expansion of macro 'rep'
   86 |     rep(i,0,m-1) hijos[U[i]].push_back(V[i],i);
      |     ^~~
islands.cpp:86:46: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int&)'
   86 |     rep(i,0,m-1) hijos[U[i]].push_back(V[i],i);
      |                                              ^
In file included from /usr/include/c++/10/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided