博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 1610 Count the Colors 线段树区间更新/暴力
阅读量:6914 次
发布时间:2019-06-27

本文共 2530 字,大约阅读时间需要 8 分钟。

Count the Colors

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610

Description

Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones.

Your task is counting the segments of different colors you can see at last.

Input

The first line of each data set contains exactly one integer n, 1 <= n <= 8000, equal to the number of colored segments.

Each of the following n lines consists of exactly 3 nonnegative integers separated by single spaces:

x1 x2 c
x1 and x2 indicate the left endpoint and right endpoint of the segment, c indicates the color of the segment.

All the numbers are in the range [0, 8000], and they are all integers.

Input may contain several data set, process to the end of file.

 

Output

Each line of the output should contain a color index that can be seen from the top, following the count of the segments of this color, they should be printed according to the color index.

If some color can't be seen, you shouldn't print it.

Print a blank line after every dataset.

 

 

 

Sample Input

5

0 4 4
0 3 1
3 4 2
0 2 2
0 2 3
4
0 1 1
3 4 1
1 3 2
1 3 1
6
0 1 0
1 2 1
2 3 1
1 2 0
2 3 0
1 2 1

 

Sample Output

1 1

2 1
3 1

1 1

0 2

1 1

 

 

 

HINT

 

题意

涂墙壁,然后问你最后能看见多少种颜色

 

题解:

数据范围太小,暴力可过,和贴海报那道题是一样的

 

代码:

 

//qscqesze#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 200001#define mod 10007#define eps 1e-9int Num;char CH[20];//const int inf=0x7fffffff; //нчоч╢Сconst int inf=0x3f3f3f3f;/*inline void P(int x){ Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts("");}*///**************************************************************************************inline ll read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}inline void P(int x){ Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts("");}int cnt[18001];int color[18001];int main(){ int n; int a,b,c; while(scanf("%d",&n)!=EOF) { memset(cnt,0,sizeof(cnt)); memset(color,0,sizeof(color)); int ma=0; for(int i=0;i

 

转载地址:http://mmncl.baihongyu.com/

你可能感兴趣的文章
Oracle与Sql server的区别
查看>>
JavaScript 判断一个对象{}是否为空对象的简单方法
查看>>
C#使用Xamarin开发可移植移动应用(1.入门与Xamarin.Forms页面),附源码
查看>>
java 正则例子
查看>>
拆系数FFT
查看>>
SpringBoot乱码
查看>>
MySQL远程连接失败(错误码:2003)
查看>>
EMQ 注意事项
查看>>
安装SQL Server时,提示VS Shell 安装失败,退出代码为 1638。
查看>>
systemd实践: 依据情况自动重启服务【转】
查看>>
Spring Security教程(五):自定义过滤器从数据库从获取资源信息
查看>>
logstash配置
查看>>
什么样的数据分析工具才是营销人最想拥有的?
查看>>
cmp()
查看>>
Linux终端回话记录和回放工具 - asciinema使用总结
查看>>
《中國姓氏大全》【带拼音】
查看>>
关于司法行政管理系统
查看>>
Themida 1.8.X 脱壳之泡泡堂不死外挂3.16
查看>>
关于tClientDataSet
查看>>
send/sendto/sendmsg函数解析
查看>>