106882024-04-08 23:35:02VargusLogisztikai központcpp17Wrong answer 6/50165ms27276 KiB
#include <iostream>
#include <queue>
#include <climits>
#include <set>
#include <algorithm>
#define ll long long

using namespace std;

struct adat
{
    bool lat = false;
    ll kolt = INT_MAX;
    vector < pair <ll, ll> > sz;
};
vector <adat> x;

struct adatt
{
    ll hova, hossz;
};
priority_queue <adatt> t;

bool operator < (const adatt& a, const adatt& b)
{
    return a.hossz > b.hossz;
}

void dijkstra(ll csp)
{
    t.push({ csp, 0 });
    x[csp].kolt = 0;
    adatt akt;
    while (!t.empty())
    {
        akt = t.top();
        t.pop();
        for (auto& e : x[akt.hova].sz)
        {
            if (x[e.first].kolt > e.second + akt.hossz)
            {
                x[e.first].kolt = e.second + akt.hossz;
                t.push({ e.first, x[e.first].kolt });
            }
        }
    }
}

int main()
{
    ll n;
    cin >> n;
    x.resize(n+1);
    for (ll i = 1; i <= n - 1; ++i)
    {
        ll cs1, cs2, kolt;
        cin >> cs1 >> cs2 >> kolt;
        x[cs1].sz.push_back({ cs2, kolt });
        x[cs2].sz.push_back({ cs1, kolt });
    }
    ll maxi = INT_MIN;
    set <ll> poz;
    for (ll i = 1; i <= n; ++i)
    {
        if (x[i].sz.size() == n - 1)
        {
            dijkstra(i);
            for (ll j = 1; j <= n; ++j)
            {
                maxi = max(maxi, x[j].kolt);
            }
            poz.insert(i);
        }
    }
    cout << maxi << "\n" << poz.size() << "\n";
    for (auto& e : poz)
        cout << e << " ";

    return 0;
}
/*
10
1 8 4
3 8 5
6 8 3
8 10 6
7 8 2
8 2 9
8 9 2
5 8 6
4 8 2
*/
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/03ms1812 KiB
2Wrong answer0/0111ms18164 KiB
3Accepted4/43ms2212 KiB
4Wrong answer0/43ms2332 KiB
5Wrong answer0/43ms2572 KiB
6Wrong answer0/43ms2736 KiB
7Wrong answer0/43ms2800 KiB
8Wrong answer0/54ms3216 KiB
9Wrong answer0/2128ms21060 KiB
10Wrong answer0/2126ms21276 KiB
11Wrong answer0/23ms3540 KiB
12Wrong answer0/24ms3728 KiB
13Wrong answer0/28ms4532 KiB
14Wrong answer0/214ms5548 KiB
15Wrong answer0/2116ms20216 KiB
16Wrong answer0/2105ms19592 KiB
17Wrong answer0/2123ms20840 KiB
18Wrong answer0/293ms16700 KiB
19Accepted2/2165ms27276 KiB
20Wrong answer0/3112ms22596 KiB