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 洛谷 题解 欧拉回路有这样一个性质,如果把所有点在平面内排成一行,路径看成区间的覆盖,那么每个点被从左往右的覆盖次数等于 ...
随机推荐
- sublime text 3 设置
最近开始用sublime text 3,查资料总结了一下常用的设置,记录下以备用,同时也希望能改大家带来方便 0.使用package control安装,点前边超链接,复制左侧代码到console,回 ...
- NOJ1012-进制转换
进制转换 时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 2214 测试通过 : 645 ...
- bat完美关机命令
@echo off title OLIVER-COMPUTER mode con cols= lines= color 0d shutdown /a >nul >nul ver > ...
- Git 设置别名[alias]
工作中我经常设置一下别名... 别名就在[alias]后面,要删除别名,直接把对应的行删掉即可. 而当前用户的Git配置文件放在用户主目录下的一个隐藏文件.gitconfig中: $ cat .git ...
- Android---WebView显示Html乱码问题
webView.loadData(result,"text/html","UTF-8"); 反正是用上面的方法无法解决乱码的问题. 使用下面的方法就能完美解决了 ...
- 011--VS2013 C++ 斜角地图贴图
准备好的图片 //全局变量HDC mdc;HBITMAP fullmap;//声明位图对象,在初始化函数中完成的斜角地图会保存在这个位图中const int rows = 10, cols = 10; ...
- java数据结构和算法------希尔排序
package iYou.neugle.sort; public class Shell_sort { public static void ShellSort(double[] array) { i ...
- Json.Net使用JSON Schema验证JSON格式
Json.NET supports the JSON Schema standard via the JsonSchema and JsonValidatingReader classes. It s ...
- Ubuntu 14.04安装配置NFS服务器
(一)安装NFS服务器1.1-安装Ubuntu nfs服务器端: sudo apt-get install nfs-kernel-server 1.2-安装nfs的客户端: sudo apt-get ...
- 4月7号周二课堂练习:NABC
团队项目——7-magic 分析特点:游戏简单容易上手 NABC分析: N(needs需求)现在存在的很多游戏操作比较,游戏规则也比较繁琐,用户很难或者不愿意去玩操作难度比较大的游戏,容易上手的游戏比 ...