CF538H.Summer Dichotomy

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

TT 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 tt 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 nn 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 ii -th teacher is willing to work in a group as long as the group will have at least lil_{i} and at most rir_{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 mm 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.

输入格式

The first line contains two space-separated integers, tt and TT ( 1<=t<=T<=1091<=t<=T<=10^{9} ).

The second line contains two space-separated integers nn and mm ( 1<=n<=1051<=n<=10^{5} , 0<=m<=1050<=m<=10^{5} ).

The ii -th of the next nn lines contain integers lil_{i} and rir_{i} ( 0<=li<=ri<=1090<=l_{i}<=r_{i}<=10^{9} ).

The next mm 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.

输出格式

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 n1n_{1} and n2n_{2} — the number of students in the first and second group, correspondingly, the contstraint t<=n1+n2<=Tt<=n_{1}+n_{2}<=T should be met. In the third line print nn characters, the ii -th of which should be 1 or 2, if the ii -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).

输入输出样例

  • 输入#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
    
首页