Codeforces 430A Points and Segments (easy)
来源:互联网 发布:膝盖伸直有响声 知乎 编辑:程序博客网 时间:2024/05/16 12:30
任何情况下都有解 不可能输出-1
将所有点排序后交替用红蓝染色 则在任意区间[li,ri]内红点个数R和蓝点个数B均满足|R-B|<=1
#include<bits/stdc++.h>using namespace std;struct points{ int c; int a;}p[120];bool cmp1(points a,points b){ return a.c<b.c;}int f[120];int main(){ int n,m,l,r; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&p[i].c); p[i].a=i; } for(int i=1;i<=m;i++) scanf("%d%d",&l,&r); sort(p+1,p+n+1,cmp1); for(int i=1;i<=n;i++) { if(i%2==0) f[p[i].a]=0; else f[p[i].a]=1; } for(int i=1;i<=n;i++) { if(i!=1) printf(" "); printf("%d",f[i]); } printf("\n"); return 0;}
0 0
- Codeforces 430A Points and Segments (easy)
- Codeforces 430 A. Points and Segments (easy)
- Codeforces 430A Points and Segments (easy)
- Codeforces Points and Segments (easy)
- Codeforces Round #245 (Div. 2) A - Points and Segments (easy)
- CodeForces 430A Points and Segments
- Codeforces 429E Points and Segments 欧拉回路
- [欧拉回路] Codeforces 429E #245 (Div. 1) E. Points and Segments
- Codeforces-289a I Polo the Penguin and Segments
- CodeForces 289A Polo the Penguin and Segments
- CodeForces 289A Polo the Penguin and Segments
- 【CODEFORCES】 A. Appleman and Easy Task
- codeforces 462A Appleman and Easy Task
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (Div. 2)A. Appleman and Easy Task
- Codeforces Round #263 (div2) A. Appleman and Easy Task
- Codeforces 462A Appleman and Easy Task(水题)
- Codeforces 802A Heidi and Library (easy) 题解
- Ubuntu下安装JDK1.8并配置开发环境
- 一个简单的HTML病毒分析
- “不愧第一” 彩妆巨头盛赞FineReport
- 通过XShell链接虚拟机的CentOS
- RTP/RTCP流媒体服务器技术研究
- Codeforces 430A Points and Segments (easy)
- 关于mysql解决中文乱码问题
- 小明陪你编游戏系列(三)第一次重构与状态机的实现
- 21世纪初最有影响力的20篇计算机视觉期刊论文 及 邓亚峰老师关于人脸识别方面总结
- leetcode第一刷_Unique Paths II
- ubuntu下安装QQ2013
- 用ASP实现简单的繁简转换
- 一则微博的感悟——一辈子做一件事
- 九度 1056 最大公约数