CF538H.Summer Dichotomy
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
T students applied into the ZPP class of Summer Irrelevant School. The organizing committee of the school may enroll any number of them, but at least t students must be enrolled. The enrolled students should be divided into two groups in any manner (it is possible that one of the groups will be empty!)
During a shift the students from the ZPP grade are tutored by n teachers. Due to the nature of the educational process, each of the teachers should be assigned to exactly one of two groups (it is possible that no teacher will be assigned to some of the groups!). The i-th teacher is willing to work in a group as long as the group will have at least l__i and at most r__i students (otherwise it would be either too boring or too hard). Besides, some pairs of the teachers don't like each other other and therefore can not work in the same group; in total there are m pairs of conflicting teachers.
You, as the head teacher of Summer Irrelevant School, have got a difficult task: to determine how many students to enroll in each of the groups and in which group each teacher will teach.
共有 T 名学生申请了暑期无关学校(Summer Irrelevant School)的 ZPP 班级。该校组委会可从中任意录取若干名学生,但至少需录取 t 名学生。被录取的学生需被划分为两个组(允许其中一组为空!)
在一次教学轮值中,ZPP 年级的学生由 n 名教师负责辅导。由于教学过程的特性,每名教师必须被恰好分配至两个组中的一个(允许某个组未被分配任何教师!)。第 i 名教师愿意在某组中任教,当且仅当该组的学生人数在 li 到 ri 之间(含端点)(否则教学将过于枯燥或过于困难)。此外,某些教师对彼此心存芥蒂,因此不能被分到同一组;此类冲突教师对总共有 m 对。
作为暑期无关学校的首席教师,您面临一项艰巨任务:确定每个组应录取多少名学生,以及每名教师应被分配至哪个组。
输入格式
The first line contains two space-separated integers, t and T (1 ≤ t ≤ T ≤ 109).
The second line contains two space-separated integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105).
The i-th of the next n lines contain integers l__i and r__i (0 ≤ l__i ≤ r__i ≤ 109).
The next m lines describe the pairs of conflicting teachers. Each of these lines contain two space-separated integers — the indices of teachers in the pair. The teachers are indexed starting from one. It is guaranteed that no teacher has a conflict with himself and no pair of conflicting teachers occurs in the list more than once.
第一行包含两个以空格分隔的整数 t 和 T(1 ≤ t ≤ T ≤ 109)。
第二行包含两个以空格分隔的整数 n 和 m(1 ≤ n ≤ 105,0 ≤ m ≤ 105)。
接下来的 n 行中,第 i 行包含两个整数 li 和 ri(0 ≤ li ≤ ri ≤ 109)。
接下来的 m 行描述相互冲突的教师对。每行包含两个以空格分隔的整数——该对中两位教师的索引(教师索引从 1 开始编号)。保证不存在教师与自身冲突,且任意一对冲突教师在列表中至多出现一次。
输出格式
If the distribution is possible, print in the first line a single word 'POSSIBLE' (without the quotes). In the second line print two space-separated integers _n_1 and _n_2 — the number of students in the first and second group, correspondingly, the contstraint t ≤ _n_1 + _n_2 ≤ T should be met. In the third line print n characters, the i-th of which should be 1 or 2, if the i-th teacher should be assigned to the first or second group, correspondingly. If there are multiple possible distributions of students and teachers in groups, you can print any of them.
If the sought distribution doesn't exist, print a single word 'IMPOSSIBLE' (without the quotes).
如果可以进行分配,则在第一行输出一个单词 'POSSIBLE'(不带引号)。
第二行输出两个用空格分隔的整数 n1 和 n2 —— 分别表示第一组和第二组的学生人数,需满足约束条件 t≤n1+n2≤T。
第三行输出 n 个字符,其中第 i 个字符为 1 或 2,分别表示第 i 位教师应被分配到第一组或第二组。
若存在多种可能的学生与教师分组方案,输出任意一种即可。
若所求的分配方案不存在,则输出一个单词 'IMPOSSIBLE'(不带引号)。
输入输出样例
输入#1
10 20 3 0 3 6 4 9 16 25
输出#1
POSSIBLE 4 16 112
输入#2
1 10 3 3 0 10 0 10 0 10 1 2 1 3 2 3
输出#2
IMPOSSIBLE
输入解题思路,AI测评打分。不知道怎么写?