Submission #82403

#TimeUsernameProblemLanguageResultExecution timeMemory
82403farukkastamonudaSightseeing (NOI14_sightseeing)C++14
25 / 25
3341 ms99588 KiB
#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)

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x,&y,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...