题号:NC232090
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Klee is developing a new type of bomb called
Peng Peng Bomb!
There are

bombs numbered from

to

, bomb

has color

. The

bombs are connected with

links, each link connects two different bombs. Bomb

will explode if meets one of the following conditions:
-
is on fire by Klee. - Bomb
connected to
and of the same color as
explodes. Formally, there exists a link between
and
, and
holds.
Klee can choose
exact 1 bomb to be on fire. You can change
at most 1 bomb

and recolor it (i.e. change

to any color you want).
Please help Klee find the maximum number of bombs can be exploded.
输入描述:
The first line of input contains two integers
and
--- the number of bombs and links respectively.
The second line contains
integers
--- the color of each bomb.
In the next
lines, each line contains two integers
--- two bombs which is connected by the link.
It is guaranteed that for any pair of bombs
, there are at most
link between them.
输出描述:
You should output an integer --- the maximum number of bombs can be exploded.
示例2
输入
复制
4 6
1 2 1 2
1 2
2 3
3 4
4 1
1 3
2 4