No.1147 Clay Figurines Ⅱ
タグ : / 解いたユーザー数 85
作問者 :
kozy
Problem Statement
$n$ clay figurines are lined up in a row.
You are given $m$ friendships between pairs of figurines. A "good relation" is defined as follows.
・Figurines in a "good relation" are not in a friend-of-a-friend relation.
・A figurine's friends of friends do not include the figurine itself or its friends.
You want to choose 3 figurines and throw them away. However, you will be cursed unless every 2 of the 3 figurines you throw away are in a "good relation".
You do not want to be cursed, so you need to choose the 3 figurines carefully. How many such ways of choosing are there?
For example, when the 3 figurines are the 2nd, 4th, and 5th from the left, (2,5,4) and (2,4,5) are not distinguished.
Input
$n \ m$ $a_1 \ b_1$ $a_2 \ b_2$ $\vdots$ $a_m \ b_m$
$3 \leq n \leq 100$, $1 \leq m \leq \dfrac{n(n-1)}{2}$
The $m$ lines from the 3rd line onward indicate that the $a_i$-th figurine from the left and the $b_i$-th figurine are friends ($a_i \neq b_i$). The same friendship may be mentioned multiple times.
$1 \leq a_i,b_i \leq n$, and all input values are integers.
Output
Output the number of ways to choose the figurines to throw away on one line.
Print a newline at the end.
Addendum: Part of the output description has been corrected. (2020/8/5-19:00)
Sample
Sample 1
Input
8 12 1 6 1 7 1 8 2 5 2 6 3 5 3 6 4 5 4 8 5 6 5 7 7 8
Output
3
Sample 2
Input
5 2 4 5 3 5
Output
7
3 and 4 are in a friend-of-a-friend relation.
Sample 3
Input
8 16 2 5 3 6 4 1 1 5 8 6 7 2 1 7 3 2 5 3 6 4 1 6 8 2 8 1 6 4 1 5 8 1
Output
3
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。