제출 #882232

#제출 시각아이디문제언어결과실행 시간메모리
882232kokoueEvacuation plan (IZhO18_plan)C++14
22 / 100
4070 ms19712 KiB
#include<bits/stdc++.h> using namespace std; int n,m,k,q; int npp[100001]; vector<pair<int,int>> edges[100001]; vector<int> sp(100001,INT_MAX); void dijkstra(int start) { priority_queue<pair<int,int>> q; vector<int> dist(n+1,INT_MAX); q.push({0,start}); dist[start]=0; sp[start]=0; while(!q.empty()) { int curr=q.top().second; int currDist=-q.top().first; q.pop(); if(dist[curr]<currDist) continue; for(auto edge:edges[curr]) { int next=edge.first; int weight=edge.second; if(dist[curr]+weight<dist[next]) { dist[next]=dist[curr]+weight; sp[next]=min(sp[next],dist[next]); q.push({-dist[next],next}); } } } } int dijkstra(int start,int finish) { priority_queue<pair<int,int>> q; vector<int> away(n+1,0); q.push({sp[start],start}); away[start]=sp[start]; while(!q.empty()) { int curr=q.top().second; int currAway=q.top().first; q.pop(); if(away[curr]>currAway) continue; for(auto edge:edges[curr]) { int next=edge.first; int len=sp[next]; if(away[next]<min(sp[next],away[curr])) { away[next]=min(sp[next],away[curr]); q.push({away[next],next}); } } } return away[finish]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; int ai,bi,wi; for(int i=0;i<m;i++) { cin>>ai>>bi>>wi; edges[ai].push_back({bi,wi}); edges[bi].push_back({ai,wi}); } cin>>k; for(int i=0;i<k;i++) { cin>>npp[i]; dijkstra(npp[i]); } cin>>q; int si,ti; for(int i=0;i<q;i++) { cin>>si>>ti; printf("%d\n",dijkstra(si,ti)); } }

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

plan.cpp: In function 'int dijkstra(int, int)':
plan.cpp:48:17: warning: unused variable 'len' [-Wunused-variable]
   48 |             int len=sp[next];
      |                 ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...