Submit solution

Points:
15 (partial)

Time limit:
0.6s

Memory limit:
162M

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given a cactus graph, compute the maximum distance between two vertices.

#### Constraints

#### Input Specification

The first line contains two space-separated integers, and . There are vertices labeled from to .

lines follow. Each line starts with an integer , followed by space-separated integers. Adjacent integers in each line are connected with an edge. The graph is guaranteed to be a connected cactus.

#### Output Specification

Output the diameter of the graph.

#### Sample Input

```
15 3
9 1 2 3 4 5 6 7 8 3
7 2 9 10 11 12 13 10
5 2 14 9 15 10
```

#### Sample Output

`8`

## Comments

This comment is hidden due to too much negative feedback. Click here to view it.