94402024-02-21 17:46:39NagyLeoKaktuszgráfpypy3Elfogadva 50/5082ms95260 KiB
from sys import stdin, stdout
input=stdin.readline

def main():
    N, M = map(int, input().split())
    graph = {}

    for i in range(M):
        A, B = map(int, input().split())
        try:
            graph[A].add(B)
        except:
            graph[A] = {B}
        try:
            graph[B].add(A)
        except:
            graph[B] = {A}
    #print(graph)

    lenCircle=0
    seen = {1:0}



    def depth_search(node, lenCircle):
        for v in graph[node]:
            if v not in seen:
                seen[v] = seen[node]+1
                lenCircle=depth_search(v, lenCircle)
            else:
                lenCircle = max(seen[node]-seen[v]+1, lenCircle)
        return lenCircle

    print(depth_search(1,lenCircle))


main()
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/043ms76688 KiB
2Elfogadva0/061ms86208 KiB
3Elfogadva2/257ms85400 KiB
4Elfogadva2/261ms86640 KiB
5Elfogadva2/267ms86456 KiB
6Elfogadva2/271ms91112 KiB
7Elfogadva2/257ms89240 KiB
8Elfogadva2/259ms89100 KiB
9Elfogadva2/270ms89792 KiB
10Elfogadva2/274ms90412 KiB
11Elfogadva2/275ms90332 KiB
12Elfogadva2/270ms90416 KiB
13Elfogadva2/278ms95260 KiB
14Elfogadva2/270ms90660 KiB
15Elfogadva2/282ms93596 KiB
16Elfogadva2/272ms91144 KiB
17Elfogadva2/271ms90428 KiB
18Elfogadva2/267ms91172 KiB
19Elfogadva3/378ms91712 KiB
20Elfogadva3/359ms91528 KiB
21Elfogadva3/363ms90548 KiB
22Elfogadva3/357ms90212 KiB
23Elfogadva3/354ms90768 KiB
24Elfogadva3/354ms90660 KiB