# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038372 | vjudge1 | 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>
#define ss second
#define pb push_back
#define mod 1000000007
#define int long long
#define N 100005
#define pu push
#define ff first
#define pint pair<int,int>
using namespace std;
int n,m,x1,y1,x2,y2;
int dis[N],vis[N],come[N],go[N],dp[N];
vector<pint> v[N];
vector<int> x;
inline void dijkstra(int start)
{
memset(dis,0,sizeof(dis));
memset(vis,0,sizeof(vis));
priority_queue<pint> pq;
pq.pu({0,start});
while(!pq.empty())
{
int ind=pq.top().ss,cost=-pq.top().ff;
pq.pop();
if(vis[ind])
continue;
vis[ind]=1;
dis[ind]=cost;
for(int i=0;i<v[ind].size();i++)
{
pq.pu({-(cost+v[ind][i].ss),v[ind][i].ff});
}
}
return;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m>>x1>>y1>>x2>>y2;
x1--;
x2--;
y1--;
y2--;
for(int i=0;i<m;i++)
{
int a,b,c;
cin>>a>>b>>c;
a--;
b--;
v[a].pb({b,c});
v[b].pb({a,c});
}
dijkstra(x1);
memset(vis,0,sizeof(vis));
queue<int> q;
q.pu(y1);
set<int> st;
while(!q.empty())
{
//break;
int ind=q.front();
q.pop();
if(vis[ind])
continue;
st.insert(ind);
vis[ind]=1;
for(int i=0;i<v[ind].size();i++)
{
if(vis[v[ind][i].ff]==0&&dis[ind]==(dis[v[ind][i].ff]+v[ind][i].ss))
{
q.pu(v[ind][i].ff);
}
}
}
int total[n];
for(int i=0;i<n;i++)
{
total[i]=0;
for(int j=0;j<v[i].size();j++)
{
if(st.count(v[i][j].ff)&&(dis[i]+v[i][j].ss)==dis[v[i][j].ff])
total[i]++;
}
}
memset(vis,0,sizeof(vis));
q.pu(y1);
while(!q.empty())
{
//break;
int ind=q.front();
q.pop();
if(vis[ind])
continue;
x.pb(ind);
vis[ind]=1;
for(int i=0;i<v[ind].size();i++)
{
total[v[ind][i].ff]--;
if(vis[v[ind][i].ff]==0&&dis[ind]==(dis[v[ind][i].ff]+v[ind][i].ss)&&!total[v[ind][i].ff])
{
q.pu(v[ind][i].ff);
}
}
}
dijkstra(x2);
for(int i=0;i<n;i++){
come[i]=dis[i];
dp[i]=10000000000000000;
}
dijkstra(y2);
for(int i=0;i<n;i++)
go[i]=dis[i];
int ans=come[y2];
for(int i=0;i<x.size();i++)
{
int ind=x[i];
int now=go[ind];
for(int j=0;j<v[ind].size();j++)
{
now=min(now,dp[v[ind][j].ff]);
}
dp[ind]=now;
ans=min(ans,dp[ind]+come[ind]);
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
commuter_pass.cpp:13:12: error: 'long long int y1' redeclared as different kind of entity 13 | int n,m,x1,y1,x2,y2; | ^~ In file included from /usr/include/features.h:461, from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518, from /usr/include/c++/10/cassert:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33, from commuter_pass.cpp:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration 'double y1(double)' 221 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ commuter_pass.cpp: In function 'void dijkstra(long long int)': commuter_pass.cpp:32:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 32 | for(int i=0;i<v[ind].size();i++) | ~^~~~~~~~~~~~~~ commuter_pass.cpp: In function 'int32_t main()': commuter_pass.cpp:44:18: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ~~~~~~~~~~~~~^~~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/10/istream:120:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]' (near match) 124 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/10/istream:124:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:131:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 131 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/10/istream:131:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'std::ios_base& (*)(std::ios_base&)' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 168 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/10/istream:168:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: warning: the address of 'double y1(double)' will never be NULL [-Waddress] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ commuter_pass.cpp:44:20: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 172 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/10/istream:172:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(short int)y1' to 'short int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:175:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 175 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/10/istream:175:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:179:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 179 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/10/istream:179:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(int)y1' to 'int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:182:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 182 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/10/istream:182:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:186:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 186 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:186:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(long int)y1' to 'long int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:190:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 190 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:190:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:195:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 195 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:195:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(long long int)y1' to 'long long int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:199:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:235:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 235 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/10/istream:235:7: note: conversion of argument 1 would be ill-formed: commuter_pass.cpp:44:20: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 44 | cin>>n>>m>>x1>>y1>>x2>>y2; | ^~ | | | double (*)(double) noexcept commuter_pass.cpp:44:20: error: cannot bind rvalue '(void*)y1' to 'void*&' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from commuter_pass.cpp:1: /usr/include/c++/10/istream:214:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' 214 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/10/istream:214:25: note: no known conversion for argument 1 from 'double(double) noexcept' to 'float&' 214 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/10/istream:218:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' 218 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/10/istream:218:26: note: no known conversion for argument 1 from 'double(double) noexcept' to 'double&' 218 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/10/istream:222:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' 222 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/10/istream:222:31: note: no known conversion for argument 1 from 'double(double) noexcept' to 'long double&' 222 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/istream:259:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]' 259 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/10/istream:259:36: note: no known conversion for argument 1 from 'double(double) noexcept' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 259 | operator>>(__streambuf_type* __sb); | ~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45, from commuter_pass.cpp:1: /usr/include/c++/10/cstddef:130:5: note: candidate: 'template<class _IntegerTyp