21662022-12-27 22:21:51bzsofiaKaktuszgráfcpp11Wrong answer 14/506ms12832 KiB
#include <iostream>
#include <fstream>
#include <vector>
#include <deque>

using namespace std;

//ifstream fin("mely.be");

struct adat
{
    bool lat;
    int tav;
    deque <int> sz;
};

int i, n, a, b, m, bejart[1001][1001], maxtav;
vector <adat> x;

void mely (int csp)
{
    //cout<<csp<<" ";
    x[csp].lat=1;
    for (auto &e:x[csp].sz)
    {
        if (!x[e].lat)
        {
            bejart[csp][e]=bejart[e][csp]=1;
            x[e].tav=x[csp].tav+1;
            mely(e);
        }else
        {
            if (!bejart[csp][e])
            {
                //cout<<csp<<" kor "<<e<<"\n";
                if (abs(x[csp].tav-x[e].tav)+1>maxtav)
                    maxtav=abs(x[csp].tav-x[e].tav)+1;
            }
            bejart[csp][e]=bejart[e][csp]=1;
        }
    }
}

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

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

    mely(1);

    cout<<maxtav;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Wrong answer0/03ms2004 KiB
2Wrong answer0/04ms5292 KiB
3Wrong answer0/23ms3512 KiB
4Wrong answer0/24ms6916 KiB
5Wrong answer0/23ms4228 KiB
6Wrong answer0/24ms8424 KiB
7Wrong answer0/26ms11472 KiB
8Accepted2/26ms11508 KiB
9Wrong answer0/24ms5588 KiB
10Wrong answer0/24ms8604 KiB
11Wrong answer0/24ms6196 KiB
12Wrong answer0/23ms5172 KiB
13Wrong answer0/24ms9172 KiB
14Wrong answer0/23ms4884 KiB
15Wrong answer0/23ms5156 KiB
16Wrong answer0/24ms8012 KiB
17Wrong answer0/24ms5348 KiB
18Wrong answer0/23ms5204 KiB
19Wrong answer0/34ms7204 KiB
20Wrong answer0/34ms12328 KiB
21Accepted3/34ms12656 KiB
22Accepted3/36ms12672 KiB
23Accepted3/36ms12832 KiB
24Accepted3/36ms12800 KiB