| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1331341 | Mamikonm1 | Crocodile's Underground City (IOI11_crocodile) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
using ll = long long;
const int n=1e5+5;
const ll inf=1e18;
struct cost{
ll mn1,mn2;
cost(ll a=inf,ll b=inf){
mn1=a;
mn2=b;
}
void add(ll x){
if(mn1>=x){
mn2=mn1;
mn1=x;
}
else if(mn2>=x)mn2=x;
}
bool operator<(cost&b){
if(mn2==b.mn2)return mn1<b.mn1;
return mn2<b.mn2;
}
}
cost dp[n];
vector<pair<int,int>>graph[n];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
int u,v;
for(int i=0;i<M;++i){
u=R[i][0];v=R[i][1];
graph[u].push_back({v,L[i]});
graph[v].push_back({u,L[i]});
}
priority_queue<pair<cost,int>,vector<pair<cost,int>>,greater<>>q;
for(int i=0;i<K;++i){
u=P[i];
dp[u]={0,0};
q.push({dp[u],u});
}
bool vis[n+1];
ll w;
while(!q.empty()){
u=q.top().second;
w=q.top().first.first;
q.pop();
if(w!=dp[u].second)continue;
for(auto&i:graph[u]){
v=i.first;
cost cur=dp[v];
cur.add(i.second+w);
if(cur<dp[v]){
dp[v]=cur;
q.push({dp[v],v});
}
}
}
return dp[0].second;
}컴파일 시 표준 에러 (stderr) 메시지
crocodile.cpp:25:6: error: expected initializer before 'dp'
25 | cost dp[n];
| ^~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
38 | dp[u]={0,0};
| ^~
| dup
crocodile.cpp:39:15: error: no matching function for call to 'std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::push(<brace-enclosed initializer list>)'
39 | q.push({dp[u],u});
| ~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
from crocodile.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<cost, int>; _Sequence = std::vector<std::pair<cost, int> >; _Compare = std::greater<void>; value_type = std::pair<cost, int>]'
738 | push(const value_type& __x)
| ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::value_type&' {aka 'const std::pair<cost, int>&'}
738 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<cost, int>; _Sequence = std::vector<std::pair<cost, int> >; _Compare = std::greater<void>; value_type = std::pair<cost, int>]'
746 | push(value_type&& __x)
| ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::value_type&&' {aka 'std::pair<cost, int>&&'}
746 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
crocodile.cpp:45:25: error: 'const struct cost' has no member named 'first'
45 | w=q.top().first.first;
| ^~~~~
crocodile.cpp:47:15: error: 'dp' was not declared in this scope; did you mean 'dup'?
47 | if(w!=dp[u].second)continue;
| ^~
| dup
crocodile.cpp:50:22: error: 'dp' was not declared in this scope; did you mean 'dup'?
50 | cost cur=dp[v];
| ^~
| dup
crocodile.cpp:54:23: error: no matching function for call to 'std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::push(<brace-enclosed initializer list>)'
54 | q.push({dp[v],v});
| ~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<cost, int>; _Sequence = std::vector<std::pair<cost, int> >; _Compare = std::greater<void>; value_type = std::pair<cost, int>]'
738 | push(const value_type& __x)
| ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::value_type&' {aka 'const std::pair<cost, int>&'}
738 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<cost, int>; _Sequence = std::vector<std::pair<cost, int> >; _Compare = std::greater<void>; value_type = std::pair<cost, int>]'
746 | push(value_type&& __x)
| ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<cost, int>, std::vector<std::pair<cost, int> >, std::greater<void> >::value_type&&' {aka 'std::pair<cost, int>&&'}
746 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
crocodile.cpp:58:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
58 | return dp[0].second;
| ^~
| dup
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
from /usr/include/c++/13/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/stl_pair.h: In instantiation of 'constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&) [with _T1 = cost; _T2 = int]':
/usr/include/c++/13/bits/stl_pair.h:849:18: required from 'constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&) [with _T1 = cost; _T2 = int]'
/usr/include/c++/13/bits/stl_function.h:546:34: required from 'static constexpr decltype(auto) std::greater<void>::_S_cmp(_Tp&&, _Up&&, std::false_type) [with _Tp = std::pair<cost, int>&; _Up = std::pair<cost, int>&; std::false_type = std::integral_constant<bool, false>]'
/usr/include/c++/13/bits/stl_function.h:531:17: required from 'constexpr decltype ((forward<_Tp>(__t) > forward<_Up>(__u))) std::greater<void>::operator()(_Tp&&, _Up&&) const [with _Tp = std::pair<cost, int>&; _Up = std::pair<cost, int>&; decltype ((forward<_Tp>(__t) > forward<_Up>(__u))) = bool]'
/usr/include/c++/13/bits/predefined_ops.h:158:30: required from 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<cost, int>*, std::vector<std::pair<cost, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<cost, int>*, std::vector<std::pair<cost, int> > >; _Compare = std::greater<void>]'
/usr/include/c++/13/bits/stl_heap.h:232:14: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<cost, int>*, vector<pair<cost, int> > >; _Distance = long int; _Tp = pair<cost, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<void> >]'
/usr/include/c++/13/bits/stl_heap.h:264:25: required from 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<cost, int>*, vector<pair<cost, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<void> >]'
/usr/include/c++/13/bits/stl_heap.h:333:19: required from 'void std::pop_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<cost, int>*, vector<pair<cost, int> > >; _Compare = greater<void>]'
/usr/include/c++/13/bits/stl_queue.h:776:15: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = std::pair<cost, int>; _Sequence = std::vector<std::pair<cost, int> >; _Compare = std::greater<void>]'
crocodile.cpp:46:14: required from here
/usr/include/c++/13/bits/stl_pair.h:836:24: error: no match for 'operator<' (operand types are 'const cost' and 'const cost')
836 | { return __x.first < __y.first
| ~~~~~~~~~~^~~~~~~~~~~
crocodile.cpp:20:10: note: candidate: 'bool cost::operator<(cost&)' (near match)
20 | bool operator<(cost&b){
| ^~~~~~~~
crocodile.cpp:20:10: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/13/bits/stl_pair.h:836:30: error: binding reference of type 'cost&' to 'const cost' discards qualifiers
836 | { return __x.first < __y.first
| ~~~~^~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
835 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note: template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_pair.h:836:24: note: 'const cost' is not derived from 'const std::pair<_T1, _T2>'
836 | { return __x.first < __y.first
| ~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:837:30: error: no match for 'operator<' (operand types are 'const cost' and 'const cost')
837 | || (!(__y.first < __x.first) && __x.second < __y.second); }
| ~~~~~~~~~~~^~~~~~~~~~~~
crocodile.cpp:20:10: note: candidate: 'bool cost::operator<(cost&)' (near match)
20 | bool operator<(cost&b){
| ^~~~~~~~
crocodile.cpp:20:10: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/13/bits/stl_pair.h:837:36: error: binding reference of type 'cost&' to 'const cost' discards qualifiers
837 | || (!(__y.first < __x.first) && __x.second < __y.second); }
| ~~~~^~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
835 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note: template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_pair.h:837:30: note: 'const cost' is not derived from 'const std::pair<_T1, _T2>'
837 | || (!(__y.first < __x.first) && __x.second < __y.second); }
| ~~~~~~~~~~~^~~~~~~~~~~~