| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 19 | 12 | 11 | 68.750% |
Bobo has an undirected graph with $n$ vertices and $m$ edges. The vertices are numbered by 1,ドル \dots, n,ドル and the $i$-th edge is between the $a_i$-th and the $b_i$-th vertex. Plus, the $i$-th vertex is associated with a character $c_i$.
Find the number of ways to choose four distinct vertices $(u, v, w, x)$ such that
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains two integers $n$ and $m$.
The second line contains $n$ characters $c_1 \dots c_n$.
For the following $m$ lines, the $i$-th line contains two integers $a_i$ and $b_i$.
For each test case, output an integer which denotes the number of ways.
5 4 bbobo 1 3 2 3 3 4 4 5 4 6 bobo 1 2 1 3 1 4 2 3 2 4 3 4 4 0 bobo
2 4 0
For the first test case, there are 2ドル$ quadrangles $(1, 3, 4, 5),ドル $(2, 3, 4, 5)$.
For the second test case, there are 4ドル$ quadrangles $(1, 2, 3, 4),ドル $(1, 4, 3, 2),ドル $(3, 2, 1, 4),ドル $(3, 4, 1, 2)$.
For the third test case, there are no valid quadrangles.