제출 #1311235

#제출 시각아이디문제언어결과실행 시간메모리
1311235hmms127Stations (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();
        return *(lower_bound(c.begin(),c.end()),t);
    }
    else {
        int idx=s;
        for(int i=0;i<c.size();i){
            if(c[i]>t){idx=i;break;}
        }
        return (idx==0 ? s:c[idx-1]);
    }
    return s;
}

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:28:29: error: no matching function for call to 'lower_bound(std::vector<int>::iterator, std::vector<int>::iterator)'
   28 |         return *(lower_bound(c.begin(),c.end()),t);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
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:29: note:   candidate expects 3 arguments, 2 provided
   28 |         return *(lower_bound(c.begin(),c.end()),t);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
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:29: note:   candidate expects 4 arguments, 2 provided
   28 |         return *(lower_bound(c.begin(),c.end()),t);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~