# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82403 | farukkastamonuda | Sightseeing (NOI14_sightseeing) | C++14 | 3341 ms | 99588 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>
#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
#define pi pair<int, pair<int,int> >
using namespace std;
int n,m,q,x,y,z,d[li],fa[li];
pair<int, pair<int,int> > p[li*10];
vector< pair<int,int> > v[li];
void dfs(int node,int ata,int val){
d[node]=val;
for(int i=0;i<(int)v[node].size();i++){
int go=v[node][i].fi;
int knr=v[node][i].se;
if(go==ata) continue;
dfs(go,node,min(val,knr));
}
}
int dsu(int x){
if(fa[x]==x) return x;
return fa[x]=dsu(fa[x]);
}
int main(){
scanf("%d %d %d",&n,&m,&q);
for(int i=1;i<=n;i++) fa[i]=i;
for(int i=1;i<=m;i++){
scanf("%d %d %d",&x,&y,&z);
p[i]=mp(z,mp(x,y));
}
sort(p+1,p+m+1,greater<pi>());
//reverse(p+1,p+m+1);
for(int i=1;i<=m;i++){
int w=p[i].fi;
int xx=p[i].se.fi;
int yy=p[i].se.se;
if(dsu(xx)!=dsu(yy)){
fa[dsu(xx)]=dsu(yy);
v[xx].pb(mp(yy,w));
v[yy].pb(mp(xx,w));
}
}
dfs(1,-1,(1<<30));
for(int i=1;i<=q;i++){
scanf("%d",&x);
printf("%d\n",d[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... |