CF744A.Hongcow Builds A Nation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.

The world can be modeled as an undirected graph with nn nodes and mm edges. kk of the nodes are home to the governments of the kk countries that make up the world.

There is at most one edge connecting any two nodes and no edge connects a node to itself. Furthermore, for any two nodes corresponding to governments, there is no path between those two nodes. Any graph that satisfies all of these conditions is stable.

Hongcow wants to add as many edges as possible to the graph while keeping it stable. Determine the maximum number of edges Hongcow can add.

输入格式

The first line of input will contain three integers nn , mm and kk ( 1<=n<=10001<=n<=1000 , 0<=m<=1000000<=m<=100000 , 1<=k<=n1<=k<=n ) — the number of vertices and edges in the graph, and the number of vertices that are homes of the government.

The next line of input will contain kk integers c1,c2,...,ckc_{1},c_{2},...,c_{k} ( 1<=ci<=n1<=c_{i}<=n ). These integers will be pairwise distinct and denote the nodes that are home to the governments in this world.

The following mm lines of input will contain two integers uiu_{i} and viv_{i} ( 1<=ui,vi<=n1<=u_{i},v_{i}<=n ). This denotes an undirected edge between nodes uiu_{i} and viv_{i} .

It is guaranteed that the graph described by the input is stable.

输出格式

Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.

输入输出样例

  • 输入#1

    4 1 2
    1 3
    1 2
    

    输出#1

    2
    
  • 输入#2

    3 3 1
    2
    1 2
    1 3
    2 3
    

    输出#2

    0
    

说明/提示

For the first sample test, the graph looks like this:

Vertices 11 and 33 are special. The optimal solution is to connect vertex 44 to vertices 11 and 22 . This adds a total of 22 edges. We cannot add any more edges, since vertices 11 and 33 cannot have any path between them.For the second sample test, the graph looks like this:

We cannot add any more edges to this graph. Note that we are not allowed to add self-loops, and the graph must be simple.

首页