标签:fine 题解 sed mes tor namespace 随机 ack com
1 #include<cstdio> 2 #include<map> 3 #include<iostream> 4 #include<vector> 5 #include<algorithm> 6 #define ull unsigned long long 7 using namespace std; 8 const int N=1000010; 9 int n,m; 10 vector<int>s[N]; 11 map<ull,int>mp; 12 map<ull,int>::iterator it; 13 int main(){ 14 freopen("bzoj4264.in","r",stdin); 15 freopen("bzoj4264.out","w",stdout); 16 scanf("%d%d",&n,&m); 17 for(int i=1,x,y;i<=m;i++){ 18 scanf("%d%d",&x,&y); 19 s[x].push_back(y); 20 s[y].push_back(x); 21 } 22 ull ans=0; 23 for(int i=1;i<=n;i++){ 24 sort(s[i].begin(),s[i].end()); 25 unique(s[i].begin(),s[i].end()); 26 ull x=0; 27 for(int j=0;j<(int)s[i].size();j++){ 28 x = x * (ull)1234567891 + s[i][j]; 29 } 30 mp[x]++; 31 } 32 for(it = mp.begin();it!=mp.end();it++){ 33 ans += (ull)it -> second * (it -> second - 1) / 2; 34 } 35 mp.clear(); 36 for(int i=1;i<=n;i++){ 37 s[i].push_back(i); 38 sort(s[i].begin(),s[i].end()); 39 unique(s[i].begin(),s[i].end()); 40 ull x=0; 41 for(int j=0;j<(int)s[i].size();j++){ 42 x = x * (ull)1234567891 + s[i][j]; 43 } 44 mp[x]++; 45 } 46 for(it = mp.begin();it!=mp.end();it++){ 47 ans += (ull)it -> second * (it -> second - 1) / 2; 48 } 49 cout << ans << endl; 50 return 0; 51 }
标签:fine 题解 sed mes tor namespace 随机 ack com
原文地址:https://www.cnblogs.com/Paul-Guderian/p/10241713.html