切水果 [Codevs1299]
来源:互联网 发布:软件开发创业项目 编辑:程序博客网 时间:2024/04/30 10:25
AC通道 :http://codevs.cn/problem/1299/
本题分析请看我另一篇博客“疯狂的馒头”。
#include <iostream>#include <cstdio>using namespace std;int fa[500010];int n,m;int find(int x){int tmp=x,pre;while(tmp!=fa[tmp])tmp=fa[tmp];while(x!=tmp){pre=fa[x];fa[x]=tmp;x=pre;}return tmp;}int main(){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++)fa[i]=i;for(int i=1;i<=m;i++){int l,r,tot=0;scanf("%d%d",&l,&r);for(int i=find(l);i<=r;i=find(i)){if(i==0)break;tot++;fa[i]=i+1;}n-=tot;printf("%d\n",n);}return 0;}
1 0
- 切水果 [Codevs1299]
- 切水果
- codevs1299 并查集
- [Unity3d]水果忍者-切水果功能
- [Unity3d]水果忍者-切水果功能
- 多线程游戏--切水果
- 开发切水果游戏
- 【wikioi1299】 切水果
- Codevs 1299 切水果
- CODEVS PROBLEM1299切水果
- scauoj_11158 切水果
- 【codevs 1299】切水果
- 【codevs 1299】切水果
- 1299 切水果
- Kinect切水果
- 水果
- 水果
- 水果
- 天声人語 20160123 甘利氏のあいまいな記憶
- Linux时间子系统之一:clock source(时钟源)
- 寒假集训
- Python
- cookie机制和session机制的区别
- 切水果 [Codevs1299]
- 做个时尚男人!变形金刚版男士护肤品包装
- linux 电源管理
- iOS开发实践之cell下载图片(SDWebImage)
- 日经春秋 20160123
- Tableview显示 老少一行解决了
- Implementing App Restrictions,Building a Device Policy Controller
- 快速掌握粒子编辑器 —— onebyonedesign网页版
- Codeforce 614A Link/Cut Tree 水题