QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3719. Dynamic Graph

统计

Bobo has a directed acyclic graph (DAG) with $n$ nodes and $m$ edges whose nodes is conveniently labeled with $1, 2, \dots, n$. All nodes are white initially.

Bobo performs $q$ operations subsequently. The $i$-th operation is to change the node $v_i$ 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.

Input

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 $a_i, b_i$.

The $i$-th of the last $q$ lines contains an integer $v_i$.

  • $2 \leq n \leq 300$
  • $1 \leq m \leq \frac{n(n - 1)}{2}$
  • $1 \leq q \leq 300$
  • $1 \leq a_i < b_i \leq n$
  • $1 \leq v_i \leq n$
  • The number of tests cases does not exceed $10$.

Output

For each operation, output an integer which denotes the number of pairs.

Sample Input

3 3 2
2 3
1 3
1 2
1
1

Sample Output

1
3
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.