ZOJ 1610 Count the Colors(线段树成端更新,暴力水过)
来源:互联网 发布:建筑能耗模拟软件 编辑:程序博客网 时间:2024/05/17 08:26
题意给出了n个操作,把(a,b)之间的线短染色,问最后能看到几段颜色分别是哪几种....
因为染色是染的线段 不是a,b之间的所有点....是开区间..但是吧...完全按照开区间又没有办法做..就弄成半开半闭区间,不过那边开都可以....闭区间连样例都过不了
另外题目中没出现的线段属于空颜色..不是任何一种...也不要统计..不然就会WA...比如给出(12 1 )(4 5 1),此时的(2,4)内都是空颜色..不统计的那种
没有用线段树做,和HDU那个Just a hook水过的方法一样...因为这俩题类似..暴力水过才10MS...卧槽这不是坑爹的么。那些一千多B两千B的代码都是几十上百...我这不到1000B的 10ms真是...
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<iostream>#include<algorithm>using namespace std;int a[10000][3],num[10000];int main(){ int n; while(scanf("%d",&n)!=EOF) { int q=-8020,i; memset(num,0,sizeof(num)); for(i=0;i<n;i++) { scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]); q=max(q,a[i][1]); } int pre=-1,now=0; for(int k=0;k<q;k++) { for(i=n-1;i>=0;i--) { if(k>=a[i][0]&&k<a[i][1])//半开半闭区间 { now=a[i][2]; break; } } if(i<0) now=-1;//没找到就是空颜色 if(now!=pre)//与前一个不一致就计数 { num[now]++; } pre=now; } for(int i=0;i<=8000;i++)//范围一定是8000 { if(num[i]>0) printf("%d %d\n",i,num[i]); } printf("\n"); } return 0;}
0 0
- ZOJ 1610 Count the Colors(线段树成端更新,暴力水过)
- ZOJ 1610 Count the Colors(暴力或者线段树)
- zoj 1610 Count the Colors(线段树延迟更新)
- ZOJ 1610 Count the Colors(线段树区间更新)
- zoj 1610 Count the Colors(线段树 区间更新)
- ZOJ 1610 Count the Colors 线段树/暴力模拟
- ZOJ 1610 Count the Colors(暴力or线段树)
- Count the Colors+ZOJ+线段树成段更新
- ZOJ 1610Count the Colors 线段树_区间更新
- zoj 1610 Count the Colors --线段树成段更新
- ZOJ 1610 Count the Colors (线段树区间更新)
- zoj 1610 Count the Colors(线段树 区间更新)
- zoj 1610 Count the Colors 线段树 区间更新
- ZOJ 1610 Count the Colors(线段树lazy+暴力统计)
- ZOJ 1610 Count the Colors(线段树,但暴力未必不行)
- zoj 1610 Count the Colors【暴力乱搞】
- zoj 1610 Count the Colors 【暴力】
- Count the Colors (线段树,暴力)
- HDU 5171GTY's birthday gift
- 【BZOJ2656】【Zjoi2012】数列(sequence) 水题,python水高精度
- 文章标题
- hibernate4.0搭建
- WMS仓库管理系统---(10)采购管理模块--采购入库
- ZOJ 1610 Count the Colors(线段树成端更新,暴力水过)
- java double 保留两位小数
- 数据结构-链表(3)
- Using lists in Android [带翻译]
- 解决MineCraft运行卡的问题(配置达到要求但一直无法解决的问题)
- C++11 lambda表达式在for_each和transform算法下的使用
- poj--3450 KMP求多个字符串的最长公共子串
- JspWriter与PrintWriter
- linux 安装oracle的java jdk