# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
369227 | chubyxdxd | 경주 (Race) (IOI11_race) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "race.h"
#include <vector>
#include <stdio.h>
#define sc second
#define ff first
/*#include <stdio.h>
#include <stdlib.h>
#define MAX_N 500000
static int N, K;
static int H[MAX_N][2];
static int L[MAX_N];
static int solution;
*/
using namespace std;
typedef pair<int,int> ii;
int mini=1e9;
int k;
/*inline
void my_assert(int e) {if (!e) abort();}
void read_input()
{
int i;
my_assert(2==scanf("%d %d",&N,&K));
for(i=0; i<N-1; i++)
my_assert(3==scanf("%d %d %d",&H[i][0],&H[i][1],&L[i]));
my_assert(1==scanf("%d",&solution));
}
*/
vector<vector<ii>> G;
void dfs(int node,int pad,int sum,int num){
if(sum==k && mini>num){
mini=num;
return;
}
if(sum>=k)return;
for(auto i:G[node]){
if(i.ff==pad)continue;
if(sum+i.sc>k || num+1>=mini)continue;
dfs(i.ff,node,sum+i.sc,num+1);
}
}
int best_path(int N, int K, int H[][2], int L[])
{
k=K;
for(int i=0;i<N-1;i++){
int a=H[i][0];
int b=H[i][1];
G[a].emplace_back(vector<ii>(1,b));
G[b].emplace_back(vector<ii>(1,a));
}
mini=1e9;
for(int i=0;i<N;i++){
dfs(i,i,0,0);
}
if(mini==1e9)mini=-1;
return mini;
}
/*
int main()
{
int ans;
read_input();
ans = best_path(N,K,H,L);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d, Expected %d.\n",ans,solution);
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)': race.cpp:50:37: error: no matching function for call to 'std::vector<std::pair<int, int> >::vector(int, int&)' 50 | G[a].emplace_back(vector<ii>(1,b)); | ^ In file included from /usr/include/c++/9/vector:67, from race.cpp:2: /usr/include/c++/9/bits/stl_vector.h:650:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&)' 650 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:650:2: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:65, from /usr/include/c++/9/vector:60, from race.cpp:2: /usr/include/c++/9/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using _RequireInputIter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<_Iterator>::iterator_category, std::input_iterator_tag>::value>::type [with _InIter = int]': /usr/include/c++/9/bits/stl_vector.h:649:9: required from here /usr/include/c++/9/bits/stl_iterator_base_types.h:232:11: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>' 232 | using _RequireInputIter = typename | ^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/9/vector:67, from race.cpp:2: /usr/include/c++/9/bits/stl_vector.h:622:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 622 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:622:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >' 622 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/9/bits/stl_vector.h:604:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 604 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:604:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >&&' 604 | vector(vector&& __rv, const allocator_type& __m) | ~~~~~~~~~^~~~ /usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::false_type = std::integral_constant<bool, false>]' 586 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::true_type = std::integral_constant<bool, true>]' 582 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/9/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 572 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:572:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::pair<int, int> >&' 572 | vector(const vector& __x, const allocator_type& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 569 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 550 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:519:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 519 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:519:47: note: no known conversion for argument 2 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'} 519 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/9/bits/stl_vector.h:507:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 507 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:507:51: note: no known conversion for argument 2 from 'int' to 'const allocator_type&' {aka 'const std::allocator<std::pair<int, int> >&'} 507 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 494 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 484 | vector() = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate expects 0 arguments, 2 provided race.cpp:51:37: error: no matching function for call to 'std::vector<std::pair<int, int> >::vector(int, int&)' 51 | G[b].emplace_back(vector<ii>(1,a)); | ^ In file included from /usr/include/c++/9/vector:67, from race.cpp:2: /usr/include/c++/9/bits/stl_vector.h:650:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&)' 650 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:650:2: note: template argument deduction/substitution failed: /usr/include/c++/9/bits/stl_vector.h:622:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 622 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:622:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >' 622 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/9/bits/stl_vector.h:604:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 604 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:604:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >&&' 604 | vector(vector&& __rv, const allocator_type& __m) | ~~~~~~~~~^~~~ /usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::false_type = std::integral_constant<bool, false>]' 586 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >; std::true_type = std::integral_constant<bool, true>]' 582 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/9/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 572 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:572:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::pair<int, int> >&' 572 | vector(const vector& __x, const allocator_type& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 569 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 550 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:519:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 519 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:519:47: note: no known conversion for argument 2 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'} 519 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/9/bits/stl_vector.h:507:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 507 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:507:51: note: no known conversion for argument 2 from 'int' to 'const allocator_type&' {aka 'const std::allocator<std::pair<int, int> >&'} 507 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::pair<int, int> >]' 494 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' 484 | vector() = default; | ^~~~~~ /usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate expects 0 arguments, 2 provided