codeforces 430A Points and Segments (easy)(理解能力有待提高……)
//终于看懂题目了,,,,
//一条线段里面不是每个坐标上都有要染色的点,所以为了满足条件,只能考虑那些给出坐标的点
//所以就要排序一下了,不能直接根据坐标0 1 0 1…… #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
struct tt
{
int a,b;
}aa[];
int cmp(tt x,tt y)
{
return x.a<y.a;
}
int cmp1(tt x,tt y)
{
return x.b<y.b;
}
int main () {
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<n;i++)
{
scanf("%d",&aa[i].a);
aa[i].b=i;
}
sort(aa,aa+n,cmp);
for(int i=;i<n;i++)
aa[i].a=i%;
int yi=;
sort(aa,aa+n,cmp1);
for(int i=;i<n;i++)
{
if(yi)printf(" ");yi=;
printf("%d",aa[i].a);
}
return ;
}
codeforces 430A Points and Segments (easy)(理解能力有待提高……)的更多相关文章
- CodeForces 430A Points and Segments (easy)(构造)题解
题意:之前愣是没看懂题意...就是给你n个点的坐标xi,然后还规定了Li,Ri,要求给每个点染色,每一组L,R内的点红色和黑色的个数不能相差大于1个,问你能不能染成功,不能输出-1,能就按照输入的顺序 ...
- Codeforces Round #245 (Div. 2) A. Points and Segments (easy) 贪心
A. Points and Segments (easy) Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- 『ACM C++』 Codeforces | 1066A - Points in Segments
大一生活真 特么 ”丰富多彩“ ,多彩到我要忙到哭泣,身为班长,很多班级的事情需要管理,也是,什么东西都得体验学一学,从学生会主席.团委团总支.社团社长都体验过一番了,现在差个班长也没试过,就来体验了 ...
- Codeforces Round #245 (Div. 2) A - Points and Segments (easy)
水到家了 #include <iostream> #include <vector> #include <algorithm> using namespace st ...
- codeforces 430 A Points and Segments (easy)
题意:给出n个点,m个区间,需要给这些点涂上蓝色或者红色,使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 唉,题目的标题就标注了一个easy= = 最开始做的时候对点还有区间都排序了 ...
- Codeforces 429E - Points and Segments(欧拉回路)
Codeforces 题面传送门 & 洛谷题面传送门 果然我不具备融会贯通的能力/ll 看到这样的设问我们可以很自然地联想到这道题,具体来说我们可以通过某种方式建出一张图,然后根据" ...
- Codeforces 429E Points and Segments
Description 题面 题目大意:有 \(n\) 个区间 \([L_i,R_i]\) ,你要给每一个区间染红蓝,使得每一个位置被红色染过的次数与被蓝色染过的次数差的绝对值不大于\(1\) Sol ...
- Codeforces Round #501 (Div. 3) 1015A Points in Segments (前缀和)
A. Points in Segments time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 【CF429E】Points and Segments(欧拉回路)
[CF429E]Points and Segments(欧拉回路) 题面 CF 洛谷 题解 欧拉回路有这样一个性质,如果把所有点在平面内排成一行,路径看成区间的覆盖,那么每个点被从左往右的覆盖次数等于 ...
随机推荐
- C# 处理csv格式的Excel文件代码
public class CSVFileHelper { /// <summary> /// 将DataTable中数据写入到CSV文件中 /// </summary> /// ...
- 刀哥多线程之主队列gcd-06-main_queue
主队列 特点 专门用来在主线程上调度任务的队列 不会开启线程 以先进先出的方式,在主线程空闲时才会调度队列中的任务在主线程执行 如果当前主线程正在有任务执行,那么无论主队列中当前被添加了什么任务,都不 ...
- UVA 10970 第一次比赛 D题 (后面才补的)
Mohammad has recently visited Switzerland. As heloves his friends very much, he decided to buy somec ...
- hdu 1303 Doubles
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1303 Doubles Description As part of an arithmetic com ...
- perl实现awk的功能
perl -nla -F/\t/ -e"...", 其中-n: while(<>){...}-l: chomp-a: autosplit-F: 与a结合的分隔模式-e: ...
- sharepoint 2010 中获取system账号的真实账号
在使用sharepoint的时候有的时候需要在后台获取当前登录用户的登录名,一般的时候使用SPContext.Current.Web.CurrentUser就可以了,但是有一个特殊的用“系统账户”,获 ...
- VBA 一些用法
另存为txt格式: Sheets().Activate ActiveWorkbook.SaveAs Filename:="E:\etl_folder\", FileFormat:= ...
- 89C51单片机定时器控制的流水灯
/***************************************************Copyright: 2014-02-11.version1.0File name: timer ...
- My mac cannot run 类相关的操作 , which is lower than 类相关的操作。
首先你选择的项目是mac项目, 其次,你MAC的系统版本小于你当前项目部署环境的最低支持版本 要么升级你的MAC系统,要么再project—>target设置developerme ...
- 通过 CALayer 修改 UIImageView 的界面属性
界面属性的修改是每一个开发者必须知道的,为什么我就记不住呢, shit, 又耽误了时间,为了防止再找不到,特把一些常用的 CALayer属性记在这里,顺便分享 1.设置阴影 1 imageView.l ...