Codeforces 155 C. Double Profiles

Source: Internet
Author: User

Codeforces 155 C. Double Profiles


Hash + sort

C. Double Profilestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 containsNRegistered profiles, numbered from 1N. Some pairs there are friends (the "friendship" relationship is mutual, that is, ifIIs friendsJ, ThenJIs also friendsI). Let's say that profilesIAndJ(I? ?J) Are doubles, if for any profileK(K? ?I,K? ?J) One of the two statements is true: eitherKIs friendsIAndJ, OrKIsn' t friends with either of them. Also,IAndJCan be friends or not be friends.

Your task is to count the number of different unordered pairs (I,?J), Such that the profilesIAndJAre doubles. Note that the pairs are unordered, that is, pairs (A,?B) And (B,?A) Are considered identical.

Input

The first line contains two space-separated integersNAndM(1? ≤?N? ≤? 106, 0? ≤?M? ≤? 106),-the number of profiles and the number of pairs of friends, correspondingly.

NextMLines contains descriptions of pairs of friends in the format"V u", WhereVAndU(1? ≤?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.

Output

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 memory ++. It is preferred to use the % I64d specificator.

Sample test (s) input
3 31 22 31 3
Output
3
Input
3 0
Output
3
Input
4 11 3
Output
2
Note

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

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


#include 
 
  #include 
  
   #include 
   
    #include using namespace std;const int maxn=1001000;typedef unsigned long long int ull;int n,m;ull p[maxn],h[maxn],g[maxn];int main(){scanf("%d%d",&n,&m);p[0]=1;for(int i=1;i<=n;i++)p[i]=p[i-1]*175;for(int i=0;i
    
     

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.