Submission #522647

# Submission time Handle Problem Language Result Execution time Memory
522647 2022-02-05T10:07:23 Z lucri Sightseeing (NOI14_sightseeing) C++17
4 / 25
865 ms 24328 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int n,m,q,x,y,c,ans[500010];
vector<vector<pair<int,int>>>a;
priority_queue<pair<int,int>>b;
bool ok[500010];
void constructie(int nod)
{
    if(ok[nod]==true)
        return;
    ok[nod]=true;
    for(auto z:a[nod])
    {
        if(min(z.second,ans[nod])>ans[z.first])
        {
            ans[z.first]=min(z.second,ans[nod]);
            b.push(make_pair(ans[z.first],z.first));
        }
    }
    if(b.empty())
        return;
    int a=b.top().second;
    b.pop();
    constructie(a);
    return;
}
int main()
{
    cin>>n>>m>>q;
    a.resize(n+5);
    for(int i=1;i<=n;++i)
    {
        cin>>x>>y>>c;
        a[x].push_back(make_pair(y,c));
        a[y].push_back(make_pair(x,c));
    }
    ans[1]=100001;
    constructie(1);
    ans[1]=0;
    for(int i=1;i<=q;++i)
    {
        cin>>x;
        cout<<ans[x]<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 2624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 865 ms 24328 KB Output isn't correct
2 Halted 0 ms 0 KB -