线段树。

假设只有一种颜色,因为每次询问有一个$x$一定是$1$,那么我可以想办法找出每一个$y$最小的$x$是多少,如果最小的都不符合,那么一定不符合,因为更新变成了单点更新,询问是区间询问最小值,搞个线段树即可。有$51$种颜色,可以搞$51$个线段树。

#include <bits/stdc++.h>
using namespace std; const int maxn = 6000000 + 10;
int op;
int root[60];
struct Node {
int val;
int L;
int R;
}s[maxn];
int num; int add() {
num ++;
s[num].val = 2000000;
s[num].L = -1;
s[num].R = -1;
return num;
} void update(int rt, int pos, int val, int l, int r) {
if(l == r) {
s[rt].val = min(s[rt].val, val);
return ;
}
int mid = (l + r) / 2;
if(pos <= mid) {
if(s[rt].L == -1) {
s[rt].L = add();
}
update(s[rt].L, pos, val, l, mid);
} else {
if(s[rt].R == -1) {
s[rt].R = add();
}
update(s[rt].R, pos, val, mid + 1, r);
}
int left = 2000000;
int right = 2000000;
if(s[rt].L != -1) {
left = s[s[rt].L].val;
}
if(s[rt].R != -1) {
right = s[s[rt].R].val;
}
s[rt].val = min(left, right);
} int query(int rt, int L, int R, int l, int r) {
if(L <= l && r <= R) {
return s[rt].val;
}
int mid = (l + r) / 2;
int left = 2000000;
int right = 2000000;
if(L <= mid && s[rt].L != -1) {
left = query(s[rt].L, L, R, l, mid);
}
if(R > mid && s[rt].R != -1) {
right = query(s[rt].R, L, R, mid + 1, r);
}
return min(left, right);
} int main() {
// freopen("D://in.txt", "r", stdin);
while(~scanf("%d", &op)) {
if(op == 0) {
for(int i = 0; i <= 50; i ++) {
root[i] = add();
}
} else if(op == 1) {
int x, y, c;
scanf("%d%d%d", &x, &y, &c);
update(root[c], y, x, 1, 1000000);
} else if(op == 2) {
int x, y1, y2;
scanf("%d%d%d", &x, &y1, &y2);
int ans = 0;
for(int i = 0; i <= 50; i ++) {
if(query(root[i], y1, y2, 1, 1000000) <= x) {
ans ++;
}
}
printf("%d\n", ans);
} else {
break;
}
}
return 0;
}

  

HDU 6183 Color it的更多相关文章

  1. HDU 6183 Color it 线段树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6183 题意: 有四种操作: 0:清除所有点 1 x y c : 给点(x, y)添加一种颜色c(颜色不 ...

  2. HDU 6183 Color it(动态开点线段树)

    题目原网址:http://acm.hdu.edu.cn/showproblem.php?pid=6183 题目中文翻译: Time Limit: 20000/10000 MS (Java/Others ...

  3. hdu 6183 Color it (线段树 动态开点)

    Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...

  4. 【刷题】HDU 6183 Color it

    Problem Description Do you like painting? Little D doesn't like painting, especially messy color pai ...

  5. HDU 6183 Color it cdq分治 + 线段树 + 状态压缩

    Color it Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) Pro ...

  6. hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  7. hdu 1556:Color the ball(线段树,区间更新,经典题)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. HDU.1556 Color the ball (线段树 区间更新 单点查询)

    HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...

  9. HDU - 6183:Color it (线段树&动态开点||CDQ分治)

    Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B ...

随机推荐

  1. Kubernetes - Deploy Containers Using YAML

    In this scenario, you'll learn how to use Kubectl to create and launch Deployments, Replication Cont ...

  2. Java SE/EE/ME概念理解(Java版本发展历史)

    继上一篇文章http://www.cnblogs.com/EasonJim/p/6181981.html中说的区别,其实分析的不够彻底,因此再次在这里做详细的分析. 零.Java与Sun.Oracle ...

  3. [转]hadoop2.x常用端口

    原文地址:http://www.zhixing123.cn/ubuntu/40649.html HDFS DataNode 50010 dfs.datanode.address datanode服务端 ...

  4. Python学习笔记(五十)爬虫的自我修养(三)爬取漂亮妹纸图

    import random import urllib from urllib import request import os ################################### ...

  5. Ajax+innerHTML+Dgls=好的用户体验+高性能+高效率

    为了引入Dgls,我们从创建Dom节点说起. 用JS创建Dom节点 var div = document.createElement('div'); div.className = 'gdls'; v ...

  6. 安装node-sass的正确姿势【转】

    安装 node-sass 的时候总是会各种不成功,今天我琢磨了一会儿总算知道要怎么解决了. 首先要知道的是,安装 node-sass 时在 node scripts/install 阶段会从 gith ...

  7. 学习Python函数笔记之二(内置函数)

    ---恢复内容开始--- 1.内置函数:取绝对值函数abs() 2.内置函数:取最大值max(),取最小值min() 3.内置函数:len()是获取序列的长度 4.内置函数:divmod(x,y),返 ...

  8. JavaScript实现水平进度条拖拽效果

    <html> <head> <meta charset="UTF-8"> <title>Document</title> ...

  9. lspci 虚拟机网卡对应关系

    我这个办法有点笨: 到 /sys/devices/ 下去搜索网卡 eth*,找到网卡对应的PCI 总线位置,例如:05:00.0. 然后通过 "lspci -s 05:00.0" ...

  10. python基础===python自带idle的快捷键

    Ctrl + [ Ctrl + ]   缩进代码Alt+3 Alt+4 注释.取消注释代码行Alt+5 Alt+6 切换缩进方式 空格<=>TabAlt+/ 单词完成,只要文中出现过,就可 ...