# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132480 | ksmzzang2003 | Commuter Pass (JOI18_commuter_pass) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define INF (1LL<<60)
typedef long long ll;
typedef pair <int,int> pii;
int N,M,S,T,U,V,deg[101010];
ll du[101010],dv[101010],d[101010],disu[101010],disv[101010],dist[101010];
vector <pii> adj[101010];
vector <int> dag[101010];
struct data{
int u,v ; ll w ;
bool operator<(const data &r)const{
return w>r.w;
}
};
priority_queue <data> pq;
queue <int> q;
int main(){
scanf("%d %d %d %d %d %d",&N,&M,&S,&T,&U,&V);
for(int i=1;i<=M;i++)
{
int u,v,w;
scanf("%d %d %d",&u,&v,&w);
adj[u].push_back(pii(v,w));
adj[v].push_back(pii(u,w));
}
for(int i=1;i<=N;i++) dist[i] = INF;
pq.push(data{0,S,0});
while(!pq.empty()){
data t = pq.top(); pq.pop();
if(t.w<=dist[t.v]) deg[t.v]++, dag[t.u].push_back(t.v);
if(t.w>=dist[t.v]) continue;
dist[t.v] = t.w;
for(pii nx: adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w});
}
for(int i=1;i<=N;i++) disv[i] = INF;
pq.push(data{0,V,0});
while(!pq.empty()){
data t = pq.top();
pq.pop();
if(t.w>=disv[t.v]) continue;
disv[t.v] = t.w;
for(pii nx:adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w});
}
q.push(S);
for(int i=1;i<=N;i++) du[i] = disu[i],dv[i] = disv[i],d[i] = INF;
while(!q.empty()){
int u = q.front(); q.pop();
d[u] = min(d[u],du[u]+disv[u]);
d[u] = min(d[u],dv[u]+disu[u]);
for(int v:dag[u]){
d[v] = min(d[v],d[u]);
du[v] = min(du[v],du[u]);
dv[v] = min(dv[v],dv[u]);
deg[v]--; if(deg[v]==0) q.push(v);
}
}
printf("%lld",min(d[T],disu[V]));
}
Compilation message (stderr)
commuter_pass.cpp:17:21: error: template argument 1 is invalid priority_queue <data> pq; ^ commuter_pass.cpp:17:21: error: template argument 2 is invalid commuter_pass.cpp:17:21: error: template argument 3 is invalid commuter_pass.cpp: In function 'int main()': commuter_pass.cpp:29:8: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push(data{0,S,0}); ^~~~ commuter_pass.cpp:29:13: error: reference to 'data' is ambiguous pq.push(data{0,S,0}); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:30:15: error: request for member 'empty' in 'pq', which is of non-class type 'int' while(!pq.empty()){ ^~~~~ commuter_pass.cpp:31:9: error: reference to 'data' is ambiguous data t = pq.top(); pq.pop(); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:31:31: error: request for member 'pop' in 'pq', which is of non-class type 'int' data t = pq.top(); pq.pop(); ^~~ commuter_pass.cpp:32:12: error: 't' was not declared in this scope if(t.w<=dist[t.v]) deg[t.v]++, dag[t.u].push_back(t.v); ^ commuter_pass.cpp:33:12: error: 't' was not declared in this scope if(t.w>=dist[t.v]) continue; ^ commuter_pass.cpp:34:14: error: 't' was not declared in this scope dist[t.v] = t.w; ^ commuter_pass.cpp:35:34: error: request for member 'push' in 'pq', which is of non-class type 'int' for(pii nx: adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~~~ commuter_pass.cpp:35:40: error: reference to 'data' is ambiguous for(pii nx: adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:35:17: warning: unused variable 'nx' [-Wunused-variable] for(pii nx: adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~ commuter_pass.cpp:38:8: error: request for member 'push' in 'pq', which is of non-class type 'int' pq.push(data{0,V,0}); ^~~~ commuter_pass.cpp:38:13: error: reference to 'data' is ambiguous pq.push(data{0,V,0}); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:39:15: error: request for member 'empty' in 'pq', which is of non-class type 'int' while(!pq.empty()){ ^~~~~ commuter_pass.cpp:40:9: error: reference to 'data' is ambiguous data t = pq.top(); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:41:12: error: request for member 'pop' in 'pq', which is of non-class type 'int' pq.pop(); ^~~ commuter_pass.cpp:42:12: error: 't' was not declared in this scope if(t.w>=disv[t.v]) continue; ^ commuter_pass.cpp:43:14: error: 't' was not declared in this scope disv[t.v] = t.w; ^ commuter_pass.cpp:44:33: error: request for member 'push' in 'pq', which is of non-class type 'int' for(pii nx:adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~~~ commuter_pass.cpp:44:39: error: reference to 'data' is ambiguous for(pii nx:adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~~~ commuter_pass.cpp:11:8: note: candidates are: struct data struct data{ ^~~~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from commuter_pass.cpp:1: /usr/include/c++/7/bits/range_access.h:318:5: note: template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>) data(initializer_list<_Tp> __il) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:309:5: note: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm]) data(_Tp (&__array)[_Nm]) noexcept ^~~~ /usr/include/c++/7/bits/range_access.h:299:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&) data(const _Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ /usr/include/c++/7/bits/range_access.h:289:5: note: template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&) data(_Container& __cont) noexcept(noexcept(__cont.data())) ^~~~ commuter_pass.cpp:44:17: warning: unused variable 'nx' [-Wunused-variable] for(pii nx:adj[t.v]) pq.push((data){t.v,nx.first,nx.second+t.w}); ^~ commuter_pass.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d %d %d %d",&N,&M,&S,&T,&U,&V); ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ commuter_pass.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d",&u,&v,&w); ~~~~~^~~~~~~~~~~~~~~~~~~~~