답안 #389787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
389787 2021-04-14T14:21:21 Z strawberry2005 관광 (NOI14_sightseeing) C++17
15 / 25
3500 ms 262144 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
const int mod = 1e9+7;
#define deb(x) cout<<#x<<": "<<x<<endl

int iceil(int a, int b) {
  return (a + b - 1) / b;
}
vector<pair<ll,ll>> adj[500001];
vector<ll> widest(500001,-mod);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);

    #ifdef strawberryshaker2005
        freopen("input.txt", "r", stdin);
    #endif

    int n,k,q;
    cin>>n>>k>>q;
    for(int i=0;i<k;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        adj[a].push_back({b,c});
        adj[b].push_back({a,c});
    }

    widest[1]=mod;pq.push({1,0});
    while(!pq.empty()){
        ll cur_node=pq.top().first,cur_d=pq.top().second;
        pq.pop();
        for(pair<ll,ll> x:adj[cur_node]){
            ll dist=max(widest[x.first],min(widest[cur_node],x.second));
            if(dist>widest[x.first]){
                widest[x.first]=dist;
                pq.push({x.first,dist});
            }
        }

    }
    for(int i=0;i<q;i++){
        ll f;
        cin>>f;
        cout<<widest[f]<<endl;
    }



    return(0);
    
}

Compilation message

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:37:36: warning: unused variable 'cur_d' [-Wunused-variable]
   37 |         ll cur_node=pq.top().first,cur_d=pq.top().second;
      |                                    ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 15952 KB Output is correct
2 Correct 10 ms 15872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 16204 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 19744 KB Output is correct
2 Correct 87 ms 18384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3583 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -