29802023-02-07 07:28:39zsebiKaktuszgráfcpp11Wrong answer 16/504ms4280 KiB
// kaktuszgraf.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>

#define ll long long
using namespace std;

struct adat
{
    bool lat,kor;
    ll be, ki,ut,honn;
    vector<ll>sz;
};
vector<adat>x;
ll n, m,a,b;

void mely(ll csp)
{
    x[csp].lat = true;
    for (auto& e : x[csp].sz)
    {
        if (!x[e].lat)
        {
            if (x[csp].ki)x[e].be = x[csp].ki + 1;
            else x[e].be = x[csp].be + 1;
            x[csp].honn = e;
            mely(e);
        }
        else
        {
            if (x[e].honn != csp)
            {
                x[e].ki = x[csp].be + 1;
                x[e].kor = true;
                x[e].ut = x[e].ki - x[e].be;
            }
        }

    }
}
int main()
{
    cin >> n >> m;
    x.resize(n + 1);
    for (int i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        x[a].sz.push_back(b);
        x[b].sz.push_back(a);
    }

    mely(1);
    ll maxi = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (x[i].kor)
        {
            maxi = max(maxi, x[i].ut);
        }
    }
    cout << maxi;
    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
base16/50
1Accepted0/03ms1872 KiB
2Wrong answer0/03ms2240 KiB
3Wrong answer0/23ms2468 KiB
4Wrong answer0/23ms2560 KiB
5Wrong answer0/23ms2544 KiB
6Wrong answer0/23ms2812 KiB
7Accepted2/23ms2784 KiB
8Accepted2/23ms3032 KiB
9Wrong answer0/23ms3240 KiB
10Wrong answer0/23ms3472 KiB
11Wrong answer0/24ms3528 KiB
12Wrong answer0/23ms3488 KiB
13Wrong answer0/23ms3492 KiB
14Wrong answer0/23ms3768 KiB
15Wrong answer0/23ms3720 KiB
16Wrong answer0/23ms3704 KiB
17Wrong answer0/24ms3952 KiB
18Wrong answer0/23ms3912 KiB
19Wrong answer0/33ms3912 KiB
20Wrong answer0/33ms4056 KiB
21Accepted3/33ms4216 KiB
22Accepted3/33ms4200 KiB
23Accepted3/33ms4268 KiB
24Accepted3/33ms4280 KiB