Submission #882053

#TimeUsernameProblemLanguageResultExecution timeMemory
882053kokoueEvacuation plan (IZhO18_plan)C++14
0 / 100
98 ms23300 KiB
#include<bits/stdc++.h> using namespace std; int n,m,k,q; int npp[10000]; vector<pair<int,int>> edges[100000]; //int sp[10000]; vector<int> sp(1000,INT_MAX); void dijkstra(int start) { // printf("Dijkstra %d: ",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()) { // printf("in while: %d->%d \n",q.top().second,q.top().first); 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}); } } } /* printf("Dijkstra %d: ",start); for(int i=0;i<=n;i++) { printf("%d:%d ",i,dist[i]); } printf("\n"); */ } int main() { scanf("%d%d",&n,&m); // fill_n(a,INT_MAX,n+1); int ai,bi,wi; for(int i=0;i<m;i++) { scanf("%d%d%d",&ai,&bi,&wi); edges[ai].push_back({bi,wi}); edges[bi].push_back({ai,wi}); } scanf("%d",&k); for(int i=0;i<k;i++) { scanf("%d",&npp[i]); dijkstra(npp[i]); } scanf("%d",&q); int si,ti; for(int i=0;i<q;i++) { scanf("%d%d",&si,&ti); printf("%d\n",min(sp[si],sp[ti])); } /* for(int i=0;i<=n;i++) { printf("%d ",sp[i]); }*/ }

Compilation message (stderr)

plan.cpp: In function 'int main()':
plan.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
plan.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         scanf("%d%d%d",&ai,&bi,&wi);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plan.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     scanf("%d",&k);
      |     ~~~~~^~~~~~~~~
plan.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         scanf("%d",&npp[i]);
      |         ~~~~~^~~~~~~~~~~~~~
plan.cpp:60:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
plan.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         scanf("%d%d",&si,&ti);
      |         ~~~~~^~~~~~~~~~~~~~~~
#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...