Codeforces Round #395 (Div. 1) D Timofey and a flat tree (树hash)
来源:互联网 发布:跑步内衣 推荐 知乎 编辑:程序博客网 时间:2024/05/22 13:10
裸的树hash,map维护一下答案即可。
int main(){ int n; cin>>n; for(int i=0;i<=2*n+2;i++){ seed[i]=((LL)rand()<<40)+((LL)rand()<<20)+rand(); } for(int i=1;i<n;i++){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); g[y].push_back(x); } dfs(1,-1); dfs2(1,-1); root=1; for(int i=2;i<=n;i++){ if(cnt.find(ha1[i])==cnt.end()){ ans++; res++; } cnt[ha1[i]]++; } dfs3(1,-1); cout<<root<<endl;}
0 0
- Codeforces Round #395 (Div. 1) D Timofey and a flat tree (树hash)
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- Codeforces Round #395 (Div. 2)Timofey and a tree
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- Codeforces Round #395 (Div. 2) C. Timofey and a tree (树的基础应用)
- Codeforces Round #395 (Div. 2) C. Timofey and a tree(树的基础应用)
- Codeforces Round 395 C Timofey and a tree 树
- 【Codeforces Round #395 (Div. 2)】Codeforces 764C Timofey and a tree
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2)D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles_0
- Codeforces Round #395 (Div. 2)-D. Timofey and rectangles
- Codeforces Round #395 (Div. 2) -- C. Timofey and a tree(并查集+缩点)
- Codeforces Round #395(Div. 2)C. Timofey and a tree【思维+并查集缩点+判定】
- Codeforces Round #395 (Div.2) C-Timofey and a tree 树型dp
- 【Codeforces763D】Timofey and a flat tree
- 设计模式
- 自我成长之模板方法模式
- hibernate
- EasyPlayer实现视频播放局部缩放、广角平移功能(类似水滴直播,快手视频)
- java一维数组和二维数组的定义及其初始化
- Codeforces Round #395 (Div. 1) D Timofey and a flat tree (树hash)
- 判断平面内一点和三角形位置关系的算法和python语言的程序实现
- CI Weekly #14 | 如何搭建合适的持续交付开发流程?
- zookeeper原理
- MySQL 高可用架构在业务层面细化分析研究
- 阿里云搭建SVN服务器
- 错误: 找不到符号
- iOS
- 【codeforces 768C】Jon Snow and his Favourite Number