CodeForces 430A Points and Segments (easy)(构造)题解
题意:之前愣是没看懂题意...就是给你n个点的坐标xi,然后还规定了Li,Ri,要求给每个点染色,每一组L,R内的点红色和黑色的个数不能相差大于1个,问你能不能染成功,不能输出-1,能就按照输入的顺序输出颜色
思路:我会说我根本没想到怎么做吗?显然只要交替染色相差就不会大于1
代码:
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn = + ;
const int MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
struct node{
int id, col, i;
bool operator < (const node x) const{
return id < x.id;
}
}a[maxn];
bool cmp(node x, node y){
return x.i < y.i;
}
int main(){
int n, m, c;
scanf("%d%d", &n, &m);
for(int i = ; i <= n; i++) scanf("%d", &a[i].id), a[i].i = i;
for(int i = ; i <= m; i++) scanf("%d%d", &c, &c);
sort(a + , a + n + );
for(int i = ; i <= n; i++) a[i].col = i & ;
sort(a + , a + n + , cmp);
for(int i = ; i <= n; i++){
if(i != ) printf(" ");
printf("%d", a[i].col);
}
printf("\n");
return ;
}
CodeForces 430A Points and Segments (easy)(构造)题解的更多相关文章
- codeforces 430A Points and Segments (easy)(理解能力有待提高……)
题目 //终于看懂题目了,,,, //一条线段里面不是每个坐标上都有要染色的点,所以为了满足条件,只能考虑那些给出坐标的点 //所以就要排序一下了,不能直接根据坐标0 1 0 1…… #include ...
- 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 ...
- 『ACM C++』 Codeforces | 1066A - Points in Segments
大一生活真 特么 ”丰富多彩“ ,多彩到我要忙到哭泣,身为班长,很多班级的事情需要管理,也是,什么东西都得体验学一学,从学生会主席.团委团总支.社团社长都体验过一番了,现在差个班长也没试过,就来体验了 ...
- Codeforces Round #245 (Div. 2) A - Points and Segments (easy)
水到家了 #include <iostream> #include <vector> #include <algorithm> using namespace st ...
- codeforces 430 A Points and Segments (easy)
题意:给出n个点,m个区间,需要给这些点涂上蓝色或者红色,使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 唉,题目的标题就标注了一个easy= = 最开始做的时候对点还有区间都排序了 ...
- Codeforces 429E - Points and Segments(欧拉回路)
Codeforces 题面传送门 & 洛谷题面传送门 果然我不具备融会贯通的能力/ll 看到这样的设问我们可以很自然地联想到这道题,具体来说我们可以通过某种方式建出一张图,然后根据" ...
- Codeforces 429E Points and Segments
Description 题面 题目大意:有 \(n\) 个区间 \([L_i,R_i]\) ,你要给每一个区间染红蓝,使得每一个位置被红色染过的次数与被蓝色染过的次数差的绝对值不大于\(1\) Sol ...
- Codeforces 576C. Points on Plane(构造)
将点先按x轴排序,把矩形竖着划分成$10^3$个块,每个块内点按y轴排序,然后蛇形走位上去. 这样一个点到下一个点的横坐标最多跨越$10^3$,一共$10^6$个点,总共$10^9$,一个块内最多走$ ...
- 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 ...
随机推荐
- centos6.5安装无线网卡驱动并配置wifi
1.驱动下载地址: RTL8188无线网卡驱动下载 链接:https://pan.baidu.com/s/1ms-EbQCDxa76jPhYUPmr9Q 密码:r2vu 2.安装步骤: [root@c ...
- [ English ] Ping sb.
What does "Ping Me" mean? Recently, when I asked a colleague to ping me, he responded wi ...
- pip install pyinstaller
C:\Users\coder211\Desktop>pip install pyinstallerCollecting pyinstaller Downloading PyInstaller-3 ...
- rpgmakermv(10) GraphicalDesignMode
插件地址:https://github.com/triacontane/RPGMakerMV/blob/master/GraphicalDesignMode.js 原文: メニュー画面や戦闘画面など各 ...
- sitecore系列教程之Sitecore个性化-体验概况概述
SITECORE 8:体验概况概述 什么是体验简介? 体验配置文件是Sitecore中的仪表板应用程序,它说明了客户体验和交互的关键区域,例如访问者详细信息,访问,活动,目标,配置文件,自动化等等. ...
- 基于TCP/IP协议的socket通讯server
思路: socket必须要随项目启动时启动,所以需用Spring自带的监听器,需要保持长连接,要用死循环,所以必须另外起线程,不能阻碍主线程运行 1.在项目的web.xml中配置listener &l ...
- tensorflow学习5----GAN模型初探
生成模型: 通过观测学习样本和标签的联合概率分布P(X,Y)进行训练,训练好的模型能够生成符合样本分布的新数据,在无监督学习方面,生成式模型能够捕获数据的高阶相关性,通过学习真实数据的本质特征,刻画样 ...
- 世界最顶级邮件服务器组合Linux + PMTA + OEMPRO,PowerMTA 安装
世界最顶级邮件服务器组合Linux + PMTA + OEMPRO PowerMTA 安装 PMTA + OEMPRO 这个是发送的组合 PMTA提供的SMTP,OEMPRO是订阅管理以及邮件的过滤 ...
- HDU 2175 汉诺塔IX (递推)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2175 1,2,...,n表示n个盘子.数字大盘子就大.n个盘子放在第1根柱子上.大盘不能放在小盘上. ...
- C#简单线程
一.实例1 static void Main(string [] args) { Console.WriteLine("开始线程"); startFunc(); Console.W ...