codeforces 430 A Points and Segments (easy)
题意:给出n个点,m个区间,需要给这些点涂上蓝色或者红色,使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1
唉,题目的标题就标注了一个easy= = 最开始做的时候对点还有区间都排序了,模拟来做,可是错了
后来发现不管区间怎么样,只要红色和蓝色交替涂色,
就一定能满足“使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 ”这个条件
有点像上次做的cf交替输出奇数偶数那个A题
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; struct node{
int x,y,z;
} a[maxn]; int cmp(node n1,node n2){
if(n1.x!=n2.x) return n1.x<n2.x;
return n1.y<n2.y;
} int main(){
int n,m;
scanf("%d %d",&n,&m);
for(int i=;i<=n;i++){
scanf("%d",&a[i].x);
a[i].y=i;
a[i].z=;
} sort(a+,a+n+,cmp); while(m--){
int u,v;
cin>>u>>v;
} for(int i=;i<=n;i++){
if(i%) a[a[i].y].z=;
else a[a[i].y].z=;
} for(int i=;i<=n;i++)
printf("%d ",a[i].z);
return ;
}
codeforces 430 A Points and Segments (easy)的更多相关文章
- 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 ...
- Codeforces Round #245 (Div. 2) A - Points and Segments (easy)
水到家了 #include <iostream> #include <vector> #include <algorithm> using namespace st ...
- codeforces 430A Points and Segments (easy)(理解能力有待提高……)
题目 //终于看懂题目了,,,, //一条线段里面不是每个坐标上都有要染色的点,所以为了满足条件,只能考虑那些给出坐标的点 //所以就要排序一下了,不能直接根据坐标0 1 0 1…… #include ...
- CodeForces 430A Points and Segments (easy)(构造)题解
题意:之前愣是没看懂题意...就是给你n个点的坐标xi,然后还规定了Li,Ri,要求给每个点染色,每一组L,R内的点红色和黑色的个数不能相差大于1个,问你能不能染成功,不能输出-1,能就按照输入的顺序 ...
- 【Codeforces 1108E1】Array and Segments (Easy version)
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举最大值和最小值在什么地方. 显然,只要包含最小值的区间,都让他减少. 因为就算那个区间包含最大值,也无所谓,因为不会让答案变小. 但是那些 ...
- 『ACM C++』 Codeforces | 1066A - Points in Segments
大一生活真 特么 ”丰富多彩“ ,多彩到我要忙到哭泣,身为班长,很多班级的事情需要管理,也是,什么东西都得体验学一学,从学生会主席.团委团总支.社团社长都体验过一番了,现在差个班长也没试过,就来体验了 ...
- 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 洛谷 题解 欧拉回路有这样一个性质,如果把所有点在平面内排成一行,路径看成区间的覆盖,那么每个点被从左往右的覆盖次数等于 ...
- 【CF429E】Points and Segments 欧拉回路
[CF429E]Points and Segments 题意:给你数轴上的n条线段$[l_i,r_i]$,你要给每条线段确定一个权值+1/-1,使得:对于数轴上的任一个点,所有包含它的线段的权值和只能 ...
随机推荐
- swfObject 使用说明
1.Embed your SWF with JavaScript 使用方法 swfobject.embedSWF(swfUrl, id, width, height, version, expres ...
- POJ 1491
#include<iostream> #include<cmath> #include<iomanip> #define MAXN 50 using namespa ...
- JUC回顾之-ThreadPoolExecutor的原理和使用
Spring中的ThreadPoolTaskExecutor是借助于JDK并发包中的java.util.concurrent.ThreadPoolExecutor来实现的.基于ThreadPoolEx ...
- Codeforces Round #263 (Div. 2) A B C
题目链接 A. Appleman and Easy Task time limit per test:2 secondsmemory limit per test:256 megabytesinput ...
- Linux目录结构【转】
使用linux也有一年多时间了 最近也是一直在维护网站系统主机 下面是linux目录结构说明 本人使用的是centos系统,很久没有发表博文了 近期会整理自己所用所了解知识点,发表linux相关的 ...
- Struts2 直接返回字符串(可用于json)
struts2可以在method中直接返回一个字符串而不是视图.让Action中的返回字符串的方法,直接return null;并在return之前用输出流输出字符串就可以了,跟servlet输出HT ...
- 14.spark RDD解密
开篇:spark各种库,sparksql,sparkmachicelearning,等这么多库底层都是封装的RDD.意味着 1:RDD本身提供了通用的抽象, 2:spark现在有5个子框架,sql,S ...
- Hadoop InputFormat OutputFormat
InputFormat有两个抽象方法: getSplits createRecordReader InputSplits 将数据按照Split进行切分,一个Split分给一个task执行. ...
- 国内银行CNAPS CODE 查询 苹果开发者,应用内购,需要填写税务相关信息必须的
https://e.czbank.com/CORPORBANK/QYUK http://weekend.blog.163.com/blog/static/746895820127961346724/
- Tomcat中xml文件引入各种schma xsd问题原理
1.Tomcat下的xml引入各种xsd约束,其实是为了对应xml中用到的各个标签