Submission #446441

#TimeUsernameProblemLanguageResultExecution timeMemory
446441jamezzzOlympic Bus (JOI20_ho_t4)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vll; mt19937 rng(time(0)); #define maxn 205 #define maxm 50005 int n,m,u[maxm],v[maxm],c[maxm],d[maxm],dd[maxn]; int dist[maxn][maxn]; vi AL[maxn]; priority_queue<ii,vector<ii>,greater<ii>> pq; int dij(int s,int t){ for(int i=0;i<n;++i)dd[i]=INF; dd[s]=0;pq.push(ii(0,s)); while(!pq.empty()){ ii pr=pq.top();pq.pop(); if(dd[pr.se]<pr.fi)continue; for(int i:AL[pr.se]){ if(dd[v[i]]>dd[u[i]]+c[i]){ dd[v[i]]=dd[u[i]]+c[i]; pq.push(ii(dd[v[i]],v[i])); } } } return dd[t]; } main(){ sf("%lld%lld",&n,&m); for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ if(i!=j)dist[i][j]=INF; } } for(int i=0;i<m;++i){ sf("%lld%lld%lld%lld",&u[i],&v[i],&c[i],&d[i]); --u[i];--v[i]; mnto(dist[u[i]][v[i]],c[i]); AL[u[i]].pb(i); } for(int k=0;k<n;++k){ for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ mnto(dist[i][j],dist[i][k]+dist[k][j]); } } } int ans=min(INF,dist[0][n-1]+dist[n-1][0]); for(int i=0;i<m;++i){ int d1=min(dist[0][n-1],dist[0][v[i]]+c[i]+dist[u[i]][n-1]); int d2=min(dist[n-1][0],dist[n-1][v[i]]+c[i]+dist[u[i]][0]); if(d1+d2+d[i]<ans){ AL[u[i]].erase(find(all(AL[u[i]]),i)); AL[v[i]].pb(i); swap(u[i],v[i]); mnto(ans,dij(0,n-1)+dij(n-1,0)+d[i]); swap(u[i],v[i]); AL[u[i]].pb(i); AL[v[i]].pop_back(); } } if(ans==INF)ans=-1; pf("%lld\n",ans); }

Compilation message (stderr)

ho_t4.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:76:43: error: no matching function for call to 'min(long int, long long int)'
   76 |  int ans=min(INF,dist[0][n-1]+dist[n-1][0]);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:76:43: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   76 |  int ans=min(INF,dist[0][n-1]+dist[n-1][0]);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ho_t4.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:76:43: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   76 |  int ans=min(INF,dist[0][n-1]+dist[n-1][0]);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:76:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   76 |  int ans=min(INF,dist[0][n-1]+dist[n-1][0]);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ho_t4.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
ho_t4.cpp:76:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   76 |  int ans=min(INF,dist[0][n-1]+dist[n-1][0]);
      |                                           ^
ho_t4.cpp:57:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |  sf("%lld%lld",&n,&m);
      |    ^
ho_t4.cpp:64:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |   sf("%lld%lld%lld%lld",&u[i],&v[i],&c[i],&d[i]);
      |     ^