Wikioi-1191-数轴染色
来源:互联网 发布:刘宇昆 爱的算法txt 编辑:程序博客网 时间:2024/04/28 23:23
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=200000+10;
int duxi[maxn*4];
int n,m;
void modify(int k, int x, int y, int l, int r)
{
if (r<x || l>y) return;
if ((y-x+1==duxi[k]) || (l<=x && r>=y))
{
duxi[k]=y+1-x;
return;
}
int m=x+(y-x)/2;
modify(2*k,x,m,l,r);
modify(2*k+1,m+1,y,l,r);
duxi[k]=duxi[2*k]+duxi[2*k+1];
}
void init()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
void readdata()
{
memset(duxi, 0, sizeof(duxi));
int x,y;
scanf("%d%d", &n, &m);
for (int i=1; i<=m; i++)
{
scanf("%d%d", &x, &y);
modify(1,1,n,x,y);
printf("%d\n", n-duxi[1]);
}
}
void work()
{
}
int main()
{
init();
readdata();
work();
return 0;
}
- Wikioi-1191-数轴染色
- wiki-1191数轴染色
- 1191 数轴染色
- Codevs 1191 数轴染色
- 【codevs 1191】数轴染色
- Codevs 1191 数轴染色
- 1191 数轴染色
- Codevs 1191 数轴染色
- 【codevs 1191】数轴染色
- 数轴染色
- 数轴染色
- codevs 1191 数轴染色 题解报告
- codevs 1191 数轴染色 模拟? 解题报告
- 【wikioi1191】 数轴染色
- wikioi1191 数轴染色
- codevs1191 数轴染色
- Codevs 数轴染色
- 【codevs1191】数轴染色
- ubuntu 12.04 下安装 PyTesser 进行OCR识别
- nginx配置文件
- Robotium源代码编译
- TSP 路径构造算法
- 通过函数指针调用函数
- Wikioi-1191-数轴染色
- object-c之从"Hello World"开始(object-c)
- 题集收集
- java语言基础
- 01-php网站
- Study notes for OpenCV——第九节 矩阵的维度、通道和矩阵的访问
- 33-定位
- eclipse怎么设置字体大小
- 建立Git Hub 与本地 Git 服务器