Submission #321650

#TimeUsernameProblemLanguageResultExecution timeMemory
321650ishi_10Sightseeing (NOI14_sightseeing)C++14
0 / 25
3473 ms262148 KiB
#include<iostream> #include<cmath> #include<bits/stdc++.h> #include<string.h> using namespace std; typedef long long int ll; const ll maxn=1e5+2; const ll mod=100000000; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,m,t; cin>>n>>m>>t; ll i,x,y,z; vector<pair<ll,ll>>adj[n+1]; vector<ll>temp[n+1]; for(i=0;i<m;i++) { cin>>x>>y>>z; adj[x].push_back({y,z}); adj[y].push_back({x,z}); temp[x].push_back(y); temp[y].push_back(x); } ll qua[n+1]; for(i=1;i<=n;i++) { qua[i]=maxn; } ll visited[n+1]={0}; ll f[n+1]={-1}; queue<pair<ll,ll>>q; q.push({0,1}); while(!q.empty()) { ll a=q.front().second; q.pop(); if(visited[a]) continue; visited[a]=1; for(auto u: adj[a]) { ll b=u.first; ll w=u.second; qua[b]=min(w,qua[a]); f[b]=max(f[b],qua[b]); q.push({-qua[b],b}); } } /*for(i=1;i<=n;i++) { cout<<qua[i]<<" "; } cout<<"\n"; for(i=1;i<=n;i++) { cout<<f[i]<<" "; } */ for(i=0;i<t;i++) { ll ab; cin>>ab; cout<<f[ab]<<"\n"; } cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...