问题2443--Dynamic Graph

2443: Dynamic Graph

时间限制: 30 Sec  内存限制: 128 MB
提交: 12  解决: 2
[提交] [状态] [讨论版] [命题人:]

题目描述

Bobo has a directed acyclic graph (DAG) with n nodes and m edges whose nodes is conveniently labeled
with 1, 2, . . . , n. All nodes are white initially.
Bobo performs q operations subsequently. The i-th operation is to change the node vi from white to black
or vice versa.
After each operation, he would like to know the number of pairs of nodes (u, v) that u, v are both white and
there exists a path from u to v passing only white nodes.

输入

The input contains zero or more test cases and is terminated by end-of-file. For each test case:
The first line contains three integers n,m and q.
The i-th of the following m lines contains two integers ai, bi.
The i-th of the last q lines contains an integer vi.
• 2 n 300
• 1 m n(n−1)/2
• 1 q 300
• 1 ai < bi n
• 1 vi n
• The number of tests cases does not exceed 10.

样例输入

3 3 2
2 3
1 3
1 2
1
1

样例输出

1
3

来源/分类


[提交] [状态]