25572023-01-17 09:14:52szabel26Logisztikai központcpp17Runtime error 8/5048ms109372 KiB
#include <iostream>
//#include <fstream>
#include <vector>
#include <deque>
#include <climits>

using namespace std;

//ifstream cin("logisztika.in");
//ofstream cout("logisztika.out");

struct csomopont{
    int lat,osszIdo;
    vector<int>sz;
    vector<int>ido{0,0,0,0,0,0,0,0,0,0,0};
};

vector<csomopont>x;
vector<int>maximumok;
vector<int>kozpontok;
deque<int>v;

int i,n,maxi=-1,a,b,c,mini,akt;

int main()
{
    cin>>n;
    x.resize(n+1);
    maximumok.resize(n+1);

    for(i=1;i<n;++i)
    {
        x[i].ido.resize(n+1);
        cin>>a>>b>>c;
        x[a].sz.push_back(b);
        x[b].sz.push_back(a);

        x[a].ido[b]=c;
        x[b].ido[a]=c;
    }

    for(i=1;i<=n;++i)
    {
        maxi=-1;
        v.push_back(i);
        x[i].lat=i;
        x[i].osszIdo=0;
        while (!v.empty())
        {
            akt=v.front();
            v.pop_front();

            for(auto &e:x[akt].sz)
                if(x[e].lat!=i)
                {
                    v.push_back(e);
                    x[e].lat=i;
                    x[e].osszIdo=x[akt].osszIdo+x[e].ido[akt];
                    if(x[e].osszIdo>maxi){
                        maxi=x[e].osszIdo;
                        //p=akt;
                    }
                }
        }
        maximumok[i]=maxi; //2.-jara nem megy bele egyik csp-be se mert mar mindegyik lat-ja==1-el
    }

    mini=INT_MAX;
    for(i=1;i<=n;++i)
    {
        if(maximumok[i]<mini) mini=maximumok[i];
    }

    for(i=1;i<=n;++i)
    {
        if(maximumok[i]==mini) kozpontok.push_back(i);
    }

    cout<<mini<<"\n";
    cout<<kozpontok.size()<<"\n";
    for(auto&e:kozpontok) cout<<e<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1816 KiB
2Runtime error0/016ms30268 KiB
3Accepted4/42ms2324 KiB
4Accepted4/42ms2492 KiB
5Runtime error0/42ms2804 KiB
6Runtime error0/42ms2892 KiB
7Runtime error0/42ms3168 KiB
8Runtime error0/53ms4072 KiB
9Runtime error0/248ms109372 KiB
10Runtime error0/230ms65584 KiB
11Runtime error0/23ms4504 KiB
12Runtime error0/23ms4512 KiB
13Runtime error0/28ms16980 KiB
14Runtime error0/213ms33956 KiB
15Runtime error0/228ms59468 KiB
16Runtime error0/214ms32232 KiB
17Runtime error0/230ms66964 KiB
18Runtime error0/212ms22008 KiB
19Runtime error0/216ms31084 KiB
20Runtime error0/317ms33476 KiB