UVA12352 Coalescing Continents

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=278&page=show_problem&problem=3774 [PDF](https://uva.onlinejudge.org/external/123/p12352.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12352/acb206ae63d98b6abb7f666eeca14dd849276add.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12352/d79a0f138979a1b2093569edac1f36614912d627.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12352/0c7c32992eb56af17eb4ba65cb4d758a3534d442.png)