제출 #736205

#제출 시각아이디문제언어결과실행 시간메모리
736205Ahmed57Commuter Pass (JOI18_commuter_pass)C++14
100 / 100
358 ms25980 KiB
#include <bits/stdc++.h> using namespace std; long long cost[4][100001]; vector<pair<int,long long>> adj[100001]; void d(int s,int ty){ priority_queue<pair<long long,long long>> q1; q1.push({0,s}); cost[ty][s] = 0; while(!q1.empty()){ long long co = q1.top().first*-1; long long no = q1.top().second; q1.pop(); if (co>cost[ty][no]) continue ; for(int i= 0;i<adj[no].size();i++){ if(cost[ty][adj[no][i].first]>(adj[no][i].second+co)){ cost[ty][adj[no][i].first] = (adj[no][i].second+co); q1.push({cost[ty][adj[no][i].first]*-1,adj[no][i].first}); } } } } long long dp[100001]; long long u,v,s,t,n,m,ans; long long solve(int a,int ty){ if(dp[a]!=-1)return dp[a]; if(cost[2][a]+cost[3][a]==cost[2][t]){ dp[a] = cost[1][a]; for(auto j:adj[a]){ if(ty?cost[2][a]+j.second==cost[2][j.first]:cost[3][a]+j.second==cost[3][j.first]){ dp[a] = min(dp[a],solve(j.first,ty)); } } ans = min(ans,dp[a]+cost[0][a]); }else dp[a] = 1e18; return dp[a]; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin>>n>>m; cin>>s>>t; cin>>u>>v; for(int i = 0;i<m;i++){ int a,b,c;cin>>a>>b>>c; adj[a].push_back({b,c}); adj[b].push_back({a,c}); } for(int i = 0;i<=n;i++){ cost[0][i] = 1e18;cost[1][i] = 1e18; cost[2][i] = 1e18;cost[3][i] = 1e18; } d(u,0);d(v,1);d(s,2);d(t,3); ans = cost[0][v]; memset(dp,-1,sizeof dp); solve(t,0); memset(dp,-1,sizeof dp); solve(s,1); cout<<ans<<endl; return 0; }

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

commuter_pass.cpp: In function 'void d(int, int)':
commuter_pass.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int i= 0;i<adj[no].size();i++){
      |                      ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...