29612023-02-06 08:29:49zsebiKaktuszgráfcpp11Wrong answer 9/503ms4328 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;
    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;
            mely(e);
        }
        else
        {
            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
base9/50
1Accepted0/03ms1876 KiB
2Wrong answer0/03ms2292 KiB
3Wrong answer0/23ms2656 KiB
4Wrong answer0/23ms2700 KiB
5Wrong answer0/23ms2664 KiB
6Wrong answer0/23ms2928 KiB
7Wrong answer0/23ms3100 KiB
8Wrong answer0/23ms3036 KiB
9Wrong answer0/23ms3288 KiB
10Wrong answer0/23ms3504 KiB
11Wrong answer0/23ms3460 KiB
12Wrong answer0/23ms3748 KiB
13Wrong answer0/23ms3672 KiB
14Wrong answer0/23ms3680 KiB
15Wrong answer0/23ms3692 KiB
16Wrong answer0/23ms3676 KiB
17Wrong answer0/23ms3812 KiB
18Wrong answer0/23ms3816 KiB
19Wrong answer0/33ms3836 KiB
20Wrong answer0/33ms4100 KiB
21Accepted3/33ms4076 KiB
22Accepted3/33ms4328 KiB
23Accepted3/33ms4284 KiB
24Wrong answer0/33ms4284 KiB