제출 #747123

#제출 시각아이디문제언어결과실행 시간메모리
7471231075508020060209tcOlympic Bus (JOI20_ho_t4)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long int n;int m; int uar[50010];int var[50010];int war[50010];int dar[50010]; int dis[210]; int rdis[210]; int vis[210]; int odis[210]; int ordis[210]; vector<pair<int,int>>e[210]; int dijkstera(){ for(int i=1;i<=n;i++){ dis[i]=1e9; vis[i]=0; rdis[i]=1e9; e[i].clear(); } for(int i=1;i<=m;i++){ e[uar[i]].push_back({var[i],war[i]}); } priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq; dis[1]=0; pq.push({0,1}); while(pq.size()){ int nw=pq.top().second; pq.pop(); if(vis[nw]){continue;} vis[nw]=1; for(int i=0;i<e[nw].size();i++){ int v=e[nw][i].first; int w=e[nw][i].second; if(dis[v]>dis[nw]+w){ dis[v]=dis[nw]+w; pq.push({dis[v],v}); } } } rdis[n]=0; pq.push({0,n}); while(pq.size()){ int nw=pq.top().second; pq.pop(); if(vis[nw]==2){continue;} vis[nw]=2; for(int i=0;i<e[nw].size();i++){ int v=e[nw][i].first; int w=e[nw][i].second; if(rdis[v]>rdis[nw]+w){ rdis[v]=rdis[nw]+w; pq.push({rdis[v],v}); } } } return dis[n]+rdis[1]; } vector<int>ee[210]; vector<int>er[210]; int dis1[210];int frm[210]; int rdis1[210];int frmn[210]; int disn[210]; int rdisn[210]; int fdis[210][210]; int isin[50010]; signed main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ fdis[i][j]=2e9; } fdis[i][i]=0; } for(int i=1;i<=m;i++){ cin>>uar[i]>>var[i]>>war[i]>>dar[i]; ee[uar[i]].push_back(i); er[var[i]].push_back(i); fdis[uar[i]][var[i]]=min(fdis[uar[i]][var[i]],war[i]); } for(int i=1;i<=n;i++){ dis1[i]=2e9; rdis1[i]=2e9; disn[i]=2e9; rdisn[i]=2e9; } priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq; dis1[1]=0; pq.push({0,1}); while(pq.size()){ int nw=pq.top().second; pq.pop(); if(vis[nw]){continue;} vis[nw]=1; for(int i=0;i<ee[nw].size();i++){ int id=ee[nw][i]; int v=var[id];int w=war[id]; if(dis1[v]>dis1[nw]+w){ dis1[v]=dis1[nw]+w; frm[v]=id; pq.push({dis1[v],v}); } } } for(int i=1;i<=n;i++){ vis[i]=0; } disn[n]=0; pq.push({0,n}); while(pq.size()){ int nw=pq.top().second; pq.pop(); if(vis[nw]){continue;} vis[nw]=1; for(int i=0;i<ee[nw].size();i++){ int id=ee[nw][i]; int v=var[id];int w=war[id]; if(disn[v]>disn[nw]+w){ disn[v]=disn[nw]+w; frmn[v]=id; pq.push({disn[v],v}); } } } for(int i=1;i<=n;i++){ for(int a=1;a<=n;a++){ for(int b=1;b<=n;b++){ fdis[a][b]=min(fdis[a][b],fdis[a][i]+fdis[i][b]); } } } if(dis1[n]<2e9){ int nw=n; while(nw!=1){ int id=frm[nw]; isin[id]=1; nw=uar[id]; } } if(disn[1]<2e9){ int nw=1; while(nw!=n){ int id=frmn[nw]; isin[id]=1; nw=uar[id]; } } long long ans=dijkstera(); //cout<<"hihi\n"; for(int i=1;i<=m;i++){ // cout<<i<<" "; if(isin[i]){ swap(uar[i],var[i]); ans=min(ans,dijkstera()+dar[i]); swap(uar[i],var[i]); }else{ // continue; int a=uar[i];int b=var[i]; long long cal=min(dis1[n],fdis[1][b]+war[i]+fdis[a][n] )+fdis[n][b]+fdis[a][1]+war[i]; cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] ); ans=min(ans,cal+dar[i]); } //} // cout<<ans<<endl; } if(ans>=3e9){ans=-1;} cout<<ans<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

ho_t4.cpp: In function 'int dijkstera()':
ho_t4.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<e[nw].size();i++){
      |                 ~^~~~~~~~~~~~~
ho_t4.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0;i<e[nw].size();i++){
      |                 ~^~~~~~~~~~~~~
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:106:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |         for(int i=0;i<ee[nw].size();i++){
      |                     ~^~~~~~~~~~~~~~
ho_t4.cpp:126:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |         for(int i=0;i<ee[nw].size();i++){
      |                     ~^~~~~~~~~~~~~~
ho_t4.cpp:168:43: error: no matching function for call to 'min(long long int&, int)'
  168 |             ans=min(ans,dijkstera()+dar[i]);
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 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 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:168:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  168 |             ans=min(ans,dijkstera()+dar[i]);
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 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 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:168:43: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  168 |             ans=min(ans,dijkstera()+dar[i]);
      |                                           ^
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:168:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  168 |             ans=min(ans,dijkstera()+dar[i]);
      |                                           ^
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:168:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  168 |             ans=min(ans,dijkstera()+dar[i]);
      |                                           ^
ho_t4.cpp:174:96: error: no matching function for call to 'min(long long int&, int)'
  174 |             cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] );
      |                                                                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 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 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:174:96: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  174 |             cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] );
      |                                                                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 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 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:174:96: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  174 |             cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] );
      |                                                                                                ^
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:174:96: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  174 |             cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] );
      |                                                                                                ^
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:174:96: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  174 |             cal=min(cal,min(disn[1],fdis[n][b]+war[i]+fdis[a][1])+fdis[1][b]+fdis[a][n]+war[i] );
      |                                                                                                ^