# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82390 | 2018-10-30T11:57:52 Z | farukkastamonuda | Sightseeing (NOI14_sightseeing) | C++14 | 3500 ms | 222580 KB |
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 500005 #define mp make_pair #define pb push_back #define mid (start+end)/2 using namespace std; int n,m,q,x,y,z,d[li]; bool vis[li]; vector< pair<int,int> > v[li]; void bfs(){ priority_queue< pair<int,int> > q; q.push(mp(inf,1)); while(!q.empty()){ pair<int,int> temp=q.top(); q.pop(); int seh=temp.se; int cst=temp.fi; if(vis[seh]) continue; vis[seh]=true; d[seh]=cst; for(int i=0;i<(int)v[seh].size();i++){ int go=v[seh][i].fi; int knr=v[seh][i].se; int nw=min(knr,cst); q.push(mp(nw,go)); } } } int main(){ scanf("%d %d %d",&n,&m,&q); for(int i=1;i<=m;i++){ scanf("%d %d %d",&x,&y,&z); v[x].pb(mp(y,z)); v[y].pb(mp(x,z)); } bfs(); for(int i=1;i<=q;i++){ scanf("%d",&x); printf("%d\n",d[x]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12124 KB | Output is correct |
2 | Correct | 12 ms | 12280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 12496 KB | Output is correct |
2 | Correct | 14 ms | 12496 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 15608 KB | Output is correct |
2 | Correct | 57 ms | 15888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3521 ms | 222580 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |