Logo
(追記) (追記ここまで)

15768번 - Duathlon 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB200745934.503%

문제

The Byteburg’s street network consists of n intersections linked by m two-way street segments. Recently, the Byteburg was chosen to host the upcoming duathlon championship. This competition consists of two legs: a running leg, followed by a cycling leg.

The route for the competition should be constructed in the following way. First, three distinct intersections s, c, and f should be chosen for start, change and finish stations. Then the route for the competition should be built. The route should start in s, go through c and end in f. For safety reasons, the route should visit each intersection at most once.

Before planning the route, the mayor wants to calculate the number of ways to choose intersections s, c, and f in such a way that it is possible to build the route for them. Help him to calculate this number.

입력

The first line contains integers n and m: number of intersections, and number of roads. Next m lines contain descriptions of roads (1 ≤ n ≤ 105, 1 ≤ m ≤ 2 · 105). Each road is described with pair of integers vi, ui, the indices of intersections connected by the road (1 ≤ vi, uin, viui). For each pair of intersections there is at most one road connecting them.

출력

Output the number of ways to choose intersections s, c, and f for start, change and finish stations, in such a way that it is possible to build the route for competition

제한

예제 입력 1

4 3
1 2
2 3
3 4

예제 출력 1

8

예제 입력 2

4 4
1 2
2 3
3 4
4 2

예제 출력 2

14

힌트

In the first example there are 8 ways to choose the triple (s, c, f): (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4), (3, 2, 1), (4, 2, 1), (4, 3, 1), (4, 3, 2).

In the second example there are 14 ways to choose the triple (s, c, f): (1, 2, 3), (1, 2, 4), (1, 3, 4), (1, 4, 3), (2, 3, 4), (2, 4, 3), (3, 2, 1), (3, 2, 4), (3, 4, 1), (3, 4, 2), (4, 2, 1), (4, 2, 3), (4, 3, 1), (4, 3, 2).

출처

Olympiad > Asia-Pacific Informatics Olympiad > APIO 2018 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /