码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces 430A Points and Segments (easy)(理解能力有待提高……)

时间:2014-09-02 22:35:05      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   for   art   

题目

 

 

 

 

bubuko.com,布布扣
//终于看懂题目了,,,,
//一条线段里面不是每个坐标上都有要染色的点,所以为了满足条件,只能考虑那些给出坐标的点
//所以就要排序一下了,不能直接根据坐标0 1 0 1……


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
struct tt
{
    int a,b;
}aa[110];
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=0;i<n;i++)
    {
        scanf("%d",&aa[i].a);
        aa[i].b=i;
    }
    sort(aa,aa+n,cmp);
    for(int i=0;i<n;i++)
        aa[i].a=i%2;
    int yi=0;
    sort(aa,aa+n,cmp1);
    for(int i=0;i<n;i++)
    {
        if(yi)printf(" ");yi=1;
        printf("%d",aa[i].a);
    }
    return 0 ;
}        
View Code

 

codeforces 430A Points and Segments (easy)(理解能力有待提高……)

标签:style   blog   http   color   os   io   ar   for   art   

原文地址:http://www.cnblogs.com/laiba2004/p/3952285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!