传统题 1000ms 256MiB

C - Tour

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Tour

Score : $300$ points

Problem Statement

The republic of AtCoder has $N$ cities numbered $1$ through $N$ and $M$ roads numbered $1$ through $M$.

Road $i$ leads from City $A_i$ to City $B_i$, but you cannot use it to get from City $B_i$ to City $A_i$.

Puma is planning her journey where she starts at some city, travels along zero or more roads, and finishes at some city.

How many pairs of cities can be the origin and destination of Puma's journey? We distinguish pairs with the same set of cities in different orders.

Constraints

  • $2 \leq N \leq 2000$
  • $0 \leq M \leq \min(2000,N(N-1))$
  • $1 \leq A_i,B_i \leq N$
  • $A_i \neq B_i$
  • $(A_i,B_i)$ are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1

\vdots

AMA_M BMB_M

Output

Print the answer.


3 3
1 2
2 3
3 2
7

We have seven pairs of cities that can be the origin and destination: $(1,1),(1,2),(1,3),(2,2),(2,3),(3,2),(3,3)$.


3 0
3

We have three pairs of cities that can be the origin and destination: $(1,1),(2,2),(3,3)$.


4 4
1 2
2 3
3 4
4 1
16

Every pair of cities can be the origin and destination.

2025春季ATC码力训练基础营第十二次比赛

未参加
状态
已结束
规则
IOI
题目
6
开始于
2025-6-14 13:00
结束于
2025-6-14 14:30
持续时间
1.5 小时
主持人
参赛人数
4