Submission #321660

# Submission time Handle Problem Language Result Execution time Memory
321660 2020-11-13T01:30:25 Z ishi_10 Sightseeing (NOI14_sightseeing) C++14
0 / 25
3002 ms 259896 KB
#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+2];
    for(i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        adj[x].push_back({y,z});
        adj[y].push_back({x,z});
    }
    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=0;i<t;i++)
    {
        ll ab;
        cin>>ab;
        cout<<f[ab]<<"\n";
    }
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
/*
4 4 2
1 2 10
1 3 30
2 4 20
3 4 5
3
4
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 5228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3002 ms 259896 KB Output isn't correct
2 Halted 0 ms 0 KB -