제출 #842561

#제출 시각아이디문제언어결과실행 시간메모리
842561irmuun가장 긴 여행 (IOI23_longesttrip)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "longesttrip.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() vector<int>longest_trip(int N, int D){ vector<int>ans; if(D==3){ vector<int>ans(N); iota(all(ans),0); return ans; } if(D==2){ vector<int>ans; ans.pb(0); int l=0,r=0; int x; for(int i=1;i<N;i++){ if(are_connected({0},{i})==true){ ans.pb(i); x=i; r=i; break; } } for(int i=1;i<N;i++){ if(i!=x){ if(are_connected({l},{i})){ ans.insert(ans.begin(),i); l=i; } else{ ans.pb(i); r=i; } } } return ans; } vector<int>v,u; int l0=0,r0=0,l1=-1,r1=-1; v.pb(0); for(int i=1;i<n;i++){ if(are_connected({l0,r0},{i})==false){ if(are_connected({l0},{i})==true){ v.insert(v.begin(),i); } else{ v.pb(i); } } else{ if(l1==-1){ u.pb(i); continue; } if(are_connected({r0},{r1})==true){ reverse(all(u)); v.insert(v.end(),u); u.clear(); u.pb(i); } else{ u.pb(i); } } } if(v.size()>=u.vize()){ return v; } return u; }

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

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:23:17: warning: variable 'r' set but not used [-Wunused-but-set-variable]
   23 |         int l=0,r=0;
      |                 ^
longesttrip.cpp:50:19: error: 'n' was not declared in this scope
   50 |     for(int i=1;i<n;i++){
      |                   ^
longesttrip.cpp:66:35: error: no matching function for call to 'std::vector<int>::insert(std::vector<int>::iterator, std::vector<int>&)'
   66 |                 v.insert(v.end(),u);
      |                                   ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from longesttrip.cpp:1:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:132:57: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
  132 |     insert(const_iterator __position, const value_type& __x)
      |                                       ~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from longesttrip.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:54: note:   no known conversion for argument 2 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1293 |       insert(const_iterator __position, value_type&& __x)
      |                                         ~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:70: note:   no known conversion for argument 2 from 'std::vector<int>' to 'std::initializer_list<int>'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
longesttrip.cpp:66:35: note:   candidate expects 3 arguments, 2 provided
   66 |                 v.insert(v.end(),u);
      |                                   ^
longesttrip.cpp:75:20: error: 'class std::vector<int>' has no member named 'vize'; did you mean 'size'?
   75 |     if(v.size()>=u.vize()){
      |                    ^~~~
      |                    size