CF154C.Double Profiles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user.

The social network contains nn registered profiles, numbered from 11 to nn . Some pairs there are friends (the "friendship" relationship is mutual, that is, if ii is friends with jj , then jj is also friends with ii ). Let's say that profiles ii and jj ( iji≠j ) are doubles, if for any profile kk ( kik≠i , kjk≠j ) one of the two statements is true: either kk is friends with ii and jj , or kk isn't friends with either of them. Also, ii and jj can be friends or not be friends.

Your task is to count the number of different unordered pairs ( i,ji,j ), such that the profiles ii and jj are doubles. Note that the pairs are unordered, that is, pairs ( a,ba,b ) and ( b,ab,a ) are considered identical.

输入格式

The first line contains two space-separated integers nn and mm ( 1<=n<=1061<=n<=10^{6} , 0<=m<=1060<=m<=10^{6} ), — the number of profiles and the number of pairs of friends, correspondingly.

Next mm lines contains descriptions of pairs of friends in the format " v uv\ u ", where vv and uu ( 1<=v,u<=n,vu1<=v,u<=n,v≠u ) are numbers of profiles that are friends with each other. It is guaranteed that each unordered pair of friends occurs no more than once and no profile is friends with itself.

输出格式

Print the single integer — the number of unordered pairs of profiles that are doubles.

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the %I64d specificator.

输入输出样例

  • 输入#1

    3 3
    1 2
    2 3
    1 3
    

    输出#1

    3
    
  • 输入#2

    3 0
    

    输出#2

    3
    
  • 输入#3

    4 1
    1 3
    

    输出#3

    2
    

说明/提示

In the first and second sample any two profiles are doubles.

In the third sample the doubles are pairs of profiles (1,3)(1,3) and (2,4)(2,4) .

首页