Submission #265362

#TimeUsernameProblemLanguageResultExecution timeMemory
265362T0p_Sightseeing (NOI14_sightseeing)C++14
15 / 25
3566 ms202684 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back struct DATA { int node, val; bool operator < (const DATA & o) const { return val < o.val; } }; int ans[500500]; priority_queue<DATA> heap; vector<DATA> g[500500]; int main() { int n, m, q; scanf(" %d %d %d",&n,&m,&q); while(m--) { int u, v, w; scanf(" %d %d %d",&u,&v,&w); g[u].pb({v, w}), g[v].pb({u, w}); } heap.push({1, 1000000000}); while(!heap.empty()) { int nown = heap.top().node; int nowv = heap.top().val; heap.pop(); for(auto x : g[nown]) { int vv = min(nowv, x.val); if(vv > ans[x.node]) { ans[x.node] = vv; heap.push({x.node, ans[x.node]}); } } } while(q--) { int d; scanf(" %d",&d); printf("%d\n",ans[d]); } return 0; }

Compilation message (stderr)

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |  scanf(" %d %d %d",&n,&m,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   scanf(" %d %d %d",&u,&v,&w);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |   scanf(" %d",&d);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...