제출 #1311247

#제출 시각아이디문제언어결과실행 시간메모리
1311247hmms127기지국 (IOI20_stations)C++20
컴파일 에러
0 ms0 KiB
//#include "stations.h" #include <vector> #include<bits/stdc++.h> #define pb push_back using namespace std; const int N=1e3+5; vector<int>labels;vector<vector<int>>adj; int cnt=0; void dfs(int node,int par,int col){ if(col==1)labels[node]=cnt++; for(auto it:adj[node])if(it!=par)dfs(it,node,col^1); if(col==0)labels[node]=cnt++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { labels.resize(n); adj.assign(n,{}); cnt=0; for(int i=0;i<n-1;i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0,-1,0); return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(c[0]>s){ if(t<s)return c.back(); int x=(lower_bound(c.begin(),c.end()),t)-c.begin(); return c[x]; } else { if(t>s)return c[0]; int idx=(upper_bound(c.begin(),c.end()),t)-c.begin(); return c[idx-1]; } return s; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:28:27: error: no matching function for call to 'lower_bound(std::vector<int>::iterator, std::vector<int>::iterator)'
   28 |         int x=(lower_bound(c.begin(),c.end()),t)-c.begin();
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from stations.cpp:2:
/usr/include/c++/13/bits/stl_algobase.h:1498:5: note: candidate: 'template<class _ForwardIterator, class _Tp> constexpr _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1498 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:1498:5: note:   template argument deduction/substitution failed:
stations.cpp:28:27: note:   candidate expects 3 arguments, 2 provided
   28 |         int x=(lower_bound(c.begin(),c.end()),t)-c.begin();
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from stations.cpp:3:
/usr/include/c++/13/bits/stl_algo.h:2005:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> constexpr _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 2005 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:2005:5: note:   template argument deduction/substitution failed:
stations.cpp:28:27: note:   candidate expects 4 arguments, 2 provided
   28 |         int x=(lower_bound(c.begin(),c.end()),t)-c.begin();
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
stations.cpp:33:29: error: no matching function for call to 'upper_bound(std::vector<int>::iterator, std::vector<int>::iterator)'
   33 |         int idx=(upper_bound(c.begin(),c.end()),t)-c.begin();
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:2061:5: note: candidate: 'template<class _FIter, class _Tp> constexpr _FIter std::upper_bound(_FIter, _FIter, const _Tp&)'
 2061 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:2061:5: note:   template argument deduction/substitution failed:
stations.cpp:33:29: note:   candidate expects 3 arguments, 2 provided
   33 |         int idx=(upper_bound(c.begin(),c.end()),t)-c.begin();
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:2092:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> constexpr _FIter std::upper_bound(_FIter, _FIter, const _Tp&, _Compare)'
 2092 |     upper_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:2092:5: note:   template argument deduction/substitution failed:
stations.cpp:33:29: note:   candidate expects 4 arguments, 2 provided
   33 |         int idx=(upper_bound(c.begin(),c.end()),t)-c.begin();
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~