CF430A.Points and Segments (easy)
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.
Iahub wants to draw n distinct points and m segments on the OX axis. He can draw each point with either red or blue. The drawing is good if and only if the following requirement is met: for each segment [l__i, r__i] consider all the red points belong to it (r__i points), and all the blue points belong to it (b__i points); each segment i should satisfy the inequality |r__i - b__i| ≤ 1.
Iahub thinks that point x belongs to segment [l, r], if inequality l ≤ x ≤ r holds.
Iahub gives to you all coordinates of points and segments. Please, help him to find any good drawing.
Iahub 在几何问题方面准备得并不充分,但他听说今年 IOI 选拔营中将出现大量几何类题目。为此感到害怕的 Iahub 锁上了地下室的门,开始思考这类新题。其中一道题如下:
Iahub 想要在 OX 轴上画出 n 个互不相同的点和 m 条线段。他可以将每个点涂成红色或蓝色。当且仅当满足以下条件时,该涂色方案被称为“好的”:对每条线段 [li,ri],设其中红色点的个数为 ri,蓝色点的个数为 bi;则对每条线段 i,都应满足不等式 ∣ri − bi∣ ≤ 1。
Iahub 认为点 x 属于线段 [l,r],当且仅当不等式 l ≤ x ≤ r 成立。
Iahub 将所有点的坐标和所有线段的信息提供给你。请帮助他找出任意一种“好的”涂色方案。
输入格式
The first line of input contains two integers: n (1 ≤ n ≤ 100) and m (1 ≤ m ≤ 100). The next line contains n space-separated integers _x_1, _x_2, ..., x__n (0 ≤ x__i ≤ 100) — the coordinates of the points. The following m lines contain the descriptions of the m segments. Each line contains two integers l__i and r__i (0 ≤ l__i ≤ r__i ≤ 100) — the borders of the i-th segment.
It's guaranteed that all the points are distinct.
输入的第一行包含两个整数:n(1 ≤ n ≤ 100)和 m(1 ≤ m ≤ 100)。
第二行包含 n 个用空格分隔的整数 x1,x2,...,xn(0 ≤ xi ≤ 100)—— 表示各点的坐标。
接下来的 m 行描述了 m 条线段。每行包含两个整数 li 和 ri(0 ≤ li ≤ ri ≤ 100)—— 表示第 i 条线段的端点边界。
保证所有点互不相同。
输出格式
If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers, each integer must be 0 or 1. The i-th number denotes the color of the i-th point (0 is red, and 1 is blue).
If there are multiple good drawings you can output any of them.
如果给定测试用例不存在合法的涂色方案,则输出单个整数 -1;否则输出 n 个整数,每个整数必须为 0 或 1。其中第 i 个数表示第 i 个点的颜色(0 表示红色,1 表示蓝色)。
若存在多个合法的涂色方案,可输出其中任意一个。
输入输出样例
输入#1
3 3 3 7 14 1 5 6 10 11 15
输出#1
0 0 0
输入#2
3 4 1 2 3 1 2 2 3 5 6 2 2
输出#2
1 0 1
输入解题思路,AI测评打分。不知道怎么写?