首页 > 代码库 > codeforces 430A Points and Segments (easy)(理解能力有待提高……)

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[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)(理解能力有待提高……)