# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29472 | 2017-07-19T12:11:06 Z | samir_droubi | Sightseeing (NOI14_sightseeing) | C++14 | 3500 ms | 101468 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 c[mxn]; 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; ++c[v]; if(c[v]>1)return 1; 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]) { ans[u]=min(vl,w); s.insert({ans[u],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 | 17648 KB | Output is correct |
2 | Correct | 3 ms | 17648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 17780 KB | Output is correct |
2 | Correct | 3 ms | 17648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 20156 KB | Output is correct |
2 | Correct | 49 ms | 19496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3500 ms | 101468 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |