AtCoder Beginner Contest 204
翻译中…
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:
翻译中…
N M
A_1 B_1
\vdots
A_M B_M
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3 3
1 2
2 3
3 2
Output #1
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)$.
Input #2
3 0
Output #2
3
We have three pairs of cities that can be the origin and destination: $(1,1),(2,2),(3,3)$.
Input #3
4 4
1 2
2 3
3 4
4 1
Output #3
16
Every pair of cities can be the origin and destination.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。