This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<algorithm>
using namespace std;
#define X first
#define Y second
typedef pair<int,int> Pi;
int V, E, q;
int st[500050], en[10000010], len[10000010], nxt[10000010];
inline void addE(int s,int e,int c,int l){nxt[c]=st[s],st[s]=c,en[c]=e,len[c]=l;}
int ans[500050];
bool chk[500050];
Pi heap[5000050];
void getInt(int &a){
	a=0;
	char c=getchar();
	while('0'<=c&&c<='9')a=(a<<3)+(a<<1)+c-'0',c=getchar();
}
int main()
{
	getInt(V), getInt(E), getInt(q);
	int i;
	for(i=1;i<=E;i++){
		int x, y, l;
		getInt(x), getInt(y), getInt(l);
		addE(x, y, i<<1, l);
		addE(y, x, i<<1|1, l);
	}
	int top = 1;
	heap[0] = Pi(1e9,1);
	while(top){
		Pi t = heap[0];
		pop_heap(heap, heap+top);
		top--;
		if(chk[t.Y])continue;
		chk[t.Y] = 1;
		ans[t.Y] = t.X;
		for(i=st[t.Y];i;i=nxt[i]){
			if(chk[en[i]])continue;
			heap[top++] = Pi(min(t.X, len[i]), en[i]);
			push_heap(heap, heap+top);
		}
	}
	while(q--){
		int x;
		getInt(x);
		printf("%d\n",ans[x]);
	}
	return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |