96192024-02-23 14:44:27PallanekPéterKaktuszgráfcpp17Wrong answer 21/504ms4968 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1001];
int mx=0;
vector<int> szin;
bool seen[1001];
int p[1001];
int kormeret(int a, int b){
    int h;
    while(a!=b){
        a=p[a]; h++;
    }
    return h+1;
}
void dfs(int x){
    if (!seen[x]){
        szin[x]=0;
        seen[x]=true;
        for(int i:g[x]){
            if (szin[i]==1) mx=max(mx,kormeret(i,x));
            if (!seen[i]){
                dfs(i);
                p[i]=x;
            }
        }
    }
    szin[x]=1;
}
int main(){
    int n,m;
    cin >> n >> m;
    	szin.assign(n+1, -1);

    for(int i=0;i<m;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    cout << mx;
}
SubtaskSumTestVerdictTimeMemory
base21/50
1Accepted0/03ms2164 KiB
2Wrong answer0/03ms2352 KiB
3Accepted2/23ms2368 KiB
4Wrong answer0/23ms2676 KiB
5Wrong answer0/23ms2892 KiB
6Wrong answer0/23ms3124 KiB
7Accepted2/23ms3232 KiB
8Accepted2/23ms3204 KiB
9Wrong answer0/23ms3208 KiB
10Wrong answer0/24ms3464 KiB
11Wrong answer0/23ms3516 KiB
12Wrong answer0/24ms3828 KiB
13Wrong answer0/23ms3892 KiB
14Wrong answer0/23ms3844 KiB
15Wrong answer0/23ms3844 KiB
16Wrong answer0/23ms3900 KiB
17Wrong answer0/23ms3900 KiB
18Wrong answer0/24ms4196 KiB
19Wrong answer0/34ms4416 KiB
20Accepted3/33ms4368 KiB
21Accepted3/33ms4660 KiB
22Accepted3/33ms4732 KiB
23Accepted3/33ms4860 KiB
24Accepted3/33ms4968 KiB