codeforces 430 A Points and Segments (easy)

题意:给出n个点,m个区间,需要给这些点涂上蓝色或者红色,使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1

唉,题目的标题就标注了一个easy= = 最开始做的时候对点还有区间都排序了,模拟来做,可是错了

后来发现不管区间怎么样,只要红色和蓝色交替涂色,

就一定能满足“使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 ”这个条件

有点像上次做的cf交替输出奇数偶数那个A题

 1 #include<iostream>  
 2 #include<cstdio>  
 3 #include<cstring> 
 4 #include <cmath> 
 5 #include<stack>
 6 #include<vector>
 7 #include<map> 
 8 #include<set>
 9 #include<queue> 
10 #include<algorithm>  
11 using namespace std;
12 
13 typedef long long LL;
14 const int INF = (1<<30)-1;
15 const int mod=1000000007;
16 const int maxn=1005;
17 
18 struct node{
19     int x,y,z;
20 } a[maxn];
21 
22 int cmp(node n1,node n2){
23     if(n1.x!=n2.x) return n1.x<n2.x;
24     return n1.y<n2.y;
25 }
26 
27 int main(){
28     int n,m;
29     scanf("%d %d",&n,&m);
30     for(int i=1;i<=n;i++){
31         scanf("%d",&a[i].x);
32         a[i].y=i;
33         a[i].z=0;
34     }
35     
36     sort(a+1,a+n+1,cmp);
37     
38     while(m--){
39         int u,v;
40         cin>>u>>v;
41     }
42     
43     for(int i=1;i<=n;i++){
44         if(i%2) a[a[i].y].z=1;
45         else a[a[i].y].z=0;
46     }
47     
48     for(int i=1;i<=n;i++)
49     printf("%d ",a[i].z);
50     return 0;
51 }
View Code

 

posted @ 2015-04-23 08:51  sequenceaa  阅读(135)  评论(0编辑  收藏  举报