| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 78667 | thebes | Sightseeing (NOI14_sightseeing) | C++14 | 3084 ms | 257620 KiB | 
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 <bits/stdc++.h>
using namespace std;
const int MN = 5e5+5;
int N, M, Q, i, x, y, ds[MN], ans[MN];
struct ed{int x, y, w;}e[10*MN];
int fnd(int x){return ds[x]=ds[x]==x?x:fnd(ds[x]);}
vector<pair<int,int>> adj[MN];
void dfs(int n,int p,int w){
    ans[n] = w;
    for(auto v : adj[n])
        if(v.first!=p) dfs(v.first,n,min(w,v.second));
}
int main(){
    for(scanf("%d%d%d",&N,&M,&Q),i=1;i<=M;i++)
        scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].w);
    sort(e+1,e+M+1,[](ed i,ed j){return i.w>j.w;});
    for(i=1;i<=N;i++) ds[i]=i;
    for(i=1;i<=M;i++){
        x=e[i].x, y=e[i].y;
        if(fnd(x)!=fnd(y)){
            ds[fnd(x)]=fnd(y);
            adj[x].push_back({y,e[i].w});
            adj[y].push_back({x,e[i].w});
        }
    }
    dfs(1, 0, 1<<30);
    for(;Q;Q--){
        scanf("%d",&x);
        printf("%d\n",ans[x]);
    }
    return 0;
}
Compilation message (stderr)
| # | 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... | ||||
