Submission #389793

# Submission time Handle Problem Language Result Execution time Memory
389793 2021-04-14T14:25:43 Z strawberry2005 Sightseeing (NOI14_sightseeing) C++17
15 / 25
3008 ms 262148 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<int,int>> adj[5000001];
vector<int> widest(5000001,-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<int,int> 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;
      |                                    ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 88 ms 137284 KB Output is correct
2 Correct 91 ms 137284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 137368 KB Output is correct
2 Correct 98 ms 137300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 140060 KB Output is correct
2 Correct 159 ms 139064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3008 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -