# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29469 | 2017-07-19T12:04:45 Z | samir_droubi | Sightseeing (NOI14_sightseeing) | C++14 | 3500 ms | 93576 KB |
#include <bits/stdc++.h> using namespace std; int n,m,q; const int mxn=(5e5)+5; vector<pair<int,int> >gr[mxn]; int ans[mxn]; set<pair<int,int> >s; int main() { scanf("%d%d%d",&n,&m,&q); for(int i=0;i<m;++i) { int x,y,w; scanf("%d%d%d",&x,&y,&w); gr[x].push_back({y,w}); gr[y].push_back({x,w}); } memset(ans,-1,sizeof ans); ans[1]=(1e9); s.insert({ans[1],1}); while(!s.empty()) { set< pair<int,int> >::iterator it=s.end(); --it; int vl=it->first; int v=it->second; s.erase(it); if(vl<ans[v])continue; ans[v]=vl; for(int i=0;i<gr[v].size();++i) { int u=gr[v][i].first; int w=gr[v][i].second; if(min(vl,w)>ans[u]) s.insert({min(vl,w),u}); } } while(q--) { int x; scanf("%d",&x); printf("%d\n",ans[x]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 15696 KB | Output is correct |
2 | Correct | 3 ms | 15696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 15960 KB | Output is correct |
2 | Correct | 3 ms | 15828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 18336 KB | Output is correct |
2 | Correct | 63 ms | 17676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3500 ms | 93576 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |