权限题

就是一个集合\(hash\)

集合\(hash\)可以用于判断两个集合是否相等,具体做法就是给每个随机一个值,之后异或起来就是可以了

这个题就是这样,处理出每个点直接相连的点集的\(hash\)值,之后判断一下有多少对\(hash\)值相等就好了

在考虑一下每条边就做完了

代码

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<map>
#define maxn 1000005
#define re register
#define LL unsigned long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
int x=0;char c=getchar();while(c<'0'||c>'9') c=getchar();
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
int u[maxn],v[maxn];
int n,m;
LL a[maxn],s[maxn];
std::map<LL,int> ma;
int main()
{
n=read(),m=read();
srand(time(0));
for(re int i=1;i<=n;i++) a[i]=((LL)(((LL)rand()<<15ll)*((LL)rand()<<12ll))^(LL)rand());
for(re int i=1;i<=m;i++) u[i]=read(),v[i]=read(),s[u[i]]^=a[v[i]],s[v[i]]^=a[u[i]];
LL ans=0;
for(re int i=1;i<=n;i++) ans+=ma[s[i]],ma[s[i]]++;
for(re int i=1;i<=m;i++) if((s[u[i]]^a[v[i]])==(s[v[i]]^a[u[i]])) ans++;
printf("%lld\n",ans);
return 0;
}

最新文章

  1. C#中的WebBrowser控件的使用
  2. 自动化测试 using System.Windows.Automation;
  3. (Hibernate进阶)Hibernate映射——一对多关联映射(七)
  4. 【转】Unity中的协同程序-使用Promise进行封装(一)
  5. ✡ leetcode 159. Longest Substring with At Most Two Distinct Characters 求两个字母组成的最大子串长度 --------- java
  6. 【Android】EventBus 源码解析
  7. 【POJ】A New Stone Game(博弈论)
  8. 【转帖】.Net中C#的DllImport的用法
  9. posix第二篇-----linux 锁机制
  10. storm kafkaSpout 踩坑问题记录! offset问题!
  11. ansible批量管理软件部署及剧本
  12. 轻量Pythonweb - flask+jinja2
  13. redis搭建主从复用-读写分离
  14. 【Linux】-NO.5.Linux.1.CentOS.1.001-【CentOS7 Foundation Configuration】-
  15. python os.path.dirname()
  16. 关于mysql中information_schema.tables
  17. NYOJ 36 LCS(最长公共子序列)
  18. bzoj2733: [HNOI2012]永无乡 线段树合并
  19. BZOJ3782 上学路线 【dp + Lucas + CRT】
  20. TOSCA自动化测试工具--Convert to Template

热门文章

  1. 记一次走心One 2 One沟通
  2. 架构实战项目心得(七):使用SpringBoot+Dubbo+Mybatisplus+Oracle搭建后台项目框架(二)
  3. Java基础(9)——数组
  4. zookeeper【6】负载均衡
  5. sass(@at-root与&amp;配合使用、without和with)
  6. html标签篇(2)
  7. C++基础--struct的大小
  8. 01_Nginx入门
  9. 微信小程序开发2-第一个小程序开发准备
  10. 第9课 备忘便签-TinyDB