제출 #396374

#제출 시각아이디문제언어결과실행 시간메모리
396374keta_tsimakuridzeCommuter Pass (JOI18_commuter_pass)C++14
100 / 100
549 ms29136 KiB
#include<bits/stdc++.h> #define f first #define int long long #define s second #define pii pair<int,int> using namespace std; const int N=2e5+5,mod=1e9+7,Inf=1e15; int t,dist[5][N],a[5],ans[N],n,m,dist1[N],Ans; vector<pair<int,int> > V[N]; vector<int> ds[2]; priority_queue<pii,vector<pii>,greater<pii> >q; string s; void Go(int I){ for(int i=1;i<=n;i++){ ans[i] = Inf; dist1[i] = Inf; } dist1[a[2]] = 0; dist1[a[0]] = dist[2][a[0]]; for(int j=0;j<ds[I].size();j++){ int v = ds[I][j]; for(int k=0;k<V[v].size();k++){ if(dist[0][V[v][k].f]<dist[0][v]) continue; dist1[V[v][k].f] = min(dist1[V[v][k].f],min(dist1[v]+V[v][k].s,dist[2][V[v][k].f])); if(dist[0][v]+dist[1][V[v][k].f]+V[v][k].s == dist[0][a[1]]) dist1[V[v][k].f] = min(dist1[V[v][k].f],dist1[v]); } } for(int i=1;i<=n;i++){ Ans=min(Ans,dist1[i]+dist[3][i]); } } main(){ // t=1; cin>>n>>m; cin>>a[0]>>a[1]>>a[2]>>a[3]; for(int i=1;i<=m;i++){ int u,v,w; cin>>u>>v>>w; V[u].push_back({v,w}); V[v].push_back({u,w}); } for(int i=0;i<4;i++){ for(int j=1;j<=n;j++) dist[i][j] = Inf; dist[i][a[i]]=0; q.push({0,a[i]}); while(q.size()){ int d=q.top().f; int u=q.top().s; if(i<=1)ds[i].push_back(u); q.pop(); if(dist[i][u]<d) continue; for(int j=0;j<V[u].size();j++){ if(dist[i][V[u][j].f]>d+V[u][j].s) { dist[i][V[u][j].f]=d+V[u][j].s; q.push({dist[i][V[u][j].f],V[u][j].f}); } } } } Ans=1e17; Go(0); swap(a[0],a[1]); swap(dist[0],dist[1]); Go(1); cout<<Ans; }

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

commuter_pass.cpp: In function 'void Go(long long int)':
commuter_pass.cpp:21:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int j=0;j<ds[I].size();j++){
      |              ~^~~~~~~~~~~~~
commuter_pass.cpp:23:17: 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]
   23 |    for(int k=0;k<V[v].size();k++){
      |                ~^~~~~~~~~~~~
commuter_pass.cpp: At global scope:
commuter_pass.cpp:36:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 |  main(){
      |       ^
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:55:17: 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]
   55 |    for(int j=0;j<V[u].size();j++){
      |                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...