시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB54242255.000%

문제

Nlogonia is a queendom that consists of several cities located on a big mountain. The capital city is Logville, located on the mountain peak. Logville has a huge lake with a perfectly round shape, appropriately named “The Big O”. This is the only lake with drinkable water in the entire queendom, so it is used to supply all cities. Some cities in Nlogonia are connected with water pipes that allow the distribution of the water. As there are no pumps, each pipe carries water from a city to another city at a lower altitude, using gravity.

Nlogonia’s water system has been a source of worries for the Queen, because since cities depend on other cities for their water supply, hot discussions occur about how much water a city is allowed to use. A water supply path is a sequence of cities in decreasing order of altitude, starting in Logville and such that there is a pipe connecting each pair of consecutive cities in the sequence. Two cities have disjoint water supply if and only if there exist two water supply paths, one supply path ending in each of the cities, such that Logville is the only city that is present in both paths. Notice that Logville itself has disjoint water supply with every other city.

The Queen considers disjoint water supply a nice property because it reduces dependency problems and also avoids water outages to spread as quickly through Nlogonia. She therefore ordered a survey to assess the current state of water supply disjointness in the whole queendom. Being the cleverest advisors in the Queen’s court, you have been summoned to help calculate the number of pairs of distinct cities that have disjoint water supply.

입력

The first line contains two integers C (2 ≤ C ≤ 1000) and P (1 ≤ P ≤ 105), representing respectively the number of cities and the number of water pipes in Nlogonia. Cities are identified with different integers from 1 to C, in strictly decreasing order of altitude (no two cities have the same altitude); Logville is city 1. Each of the next P lines describes a pipe with two integers U and V (1 ≤ U < V ≤ C) indicating that the pipe connects city U with city V . You may assume that no two pipes connect the same pair of cities, and that for each city in Nlogonia there is at least one water supply path that ends in it.

출력

Output a line with an integer representing the number of pairs of distinct cities that have disjoint water supply.

예제 입력 1

6 6
1 2
1 3
1 4
2 5
2 6
3 6

예제 출력 1

14

출처

ICPC > Regionals > Latin America > Latin America Regional Contests 2013 D번

  • 문제를 만든 사람: Jesus Alejandro Peña Mesias