23092023-01-10 09:41:06bzsofiaLogisztikai központcpp11Time limit exceeded 31/501.1s12600 KiB
// Logisztikai kozpont.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <queue>

using namespace std;

ifstream fin("be.in");

long long a, b, c, i, n, kezd, akt, maxt, mint = 9999999999999999;
queue <long long> s;
vector <long long> mini;

struct adat
{
    long long tav;
    bool lat;
    vector <pair <long long, long long>> sz;
};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    vector <adat> x(n + 1);
    //vector <vector<long long>> ido(n + 1, vector <long long>(n + 1));
    for (i = 1; i < n; ++i)
    {
        cin >> a >> b >> c;
        //ido[a][b] = ido[b][a] = c;

        x[a].sz.push_back({ b,c });
        x[b].sz.push_back({ a,c });
    }

    for (kezd = 1; kezd <= n; ++kezd)
    {
        for (i = 1; i <= n; ++i)
        {
            x[i].lat = 0;
            x[i].tav = 0;
        }

        x[kezd].lat = 1;
        s.push(kezd);
        while (!s.empty())
        {
            akt = s.front();
            s.pop();
            for (auto& e : x[akt].sz)
            {
                if (!x[e.first].lat)
                {
                    x[e.first].lat = 1;
                    x[e.first].tav = x[akt].tav + e.second;
                    s.push(e.first);
                }
            }
        }

        maxt = 0;
        for (i = 1; i <= n; ++i)
        {
            if (x[i].tav > maxt)
            {
                maxt = x[i].tav;
            }
        }

        if (maxt < mint)
        {
            mint = maxt;
            mini.clear();
            mini.push_back(kezd);
        }
        else if (maxt == mint) mini.push_back(kezd);
    }

    cout << mint << "\n" << mini.size() << "\n";
    for (auto& e : mini) cout << e << " ";

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base31/50
1Accepted0/03ms1700 KiB
2Time limit exceeded0/01.1s9448 KiB
3Accepted4/42ms2180 KiB
4Accepted4/42ms2400 KiB
5Accepted4/42ms2500 KiB
6Accepted4/42ms2572 KiB
7Accepted4/42ms2564 KiB
8Accepted5/532ms2900 KiB
9Time limit exceeded0/21.083s11444 KiB
10Time limit exceeded0/21.087s11520 KiB
11Accepted2/27ms3484 KiB
12Accepted2/263ms3740 KiB
13Accepted2/2925ms4060 KiB
14Time limit exceeded0/21.052s3528 KiB
15Time limit exceeded0/21.078s11144 KiB
16Time limit exceeded0/21.07s10816 KiB
17Time limit exceeded0/21.07s11816 KiB
18Time limit exceeded0/21.059s9440 KiB
19Time limit exceeded0/21.062s12452 KiB
20Time limit exceeded0/31.059s12600 KiB