CF1250K.Projectors

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There are nn lectures and mm seminars to be conducted today at the Faculty of Approximate Sciences. The ii -th lecture starts at aia_i and ends at bib_i (formally, time of the lecture spans an interval [ai,bi)[a_i, b_i) , the right bound is exclusive). The jj -th seminar starts at pjp_j and ends at qjq_j (similarly, time of the seminar spans an interval [pj,qj)[p_j, q_j) , the right bound is exclusive).

There are xx HD-projectors numbered from 11 to xx and yy ordinary projectors numbered from x+1x + 1 to x+yx + y available at the faculty. Projectors should be distributed in such a way that:

  • an HD-projector is used in each lecture;
  • some projector (ordinary or HD) is used in each seminar;
  • a projector (ordinary or HD) can only be used in one event at the same moment of time;
  • if a projector is selected for an event, it is used there for the whole duration of the event;
  • a projector can be reused in some following event, if it starts not earlier than current event finishes.

You are to find such distribution of projectors, if it exists.

Again, note that the right bound of the event's time range is not inclusive: if some event starts exactly when another event finishes, the projector can be reused (suppose that it is instantly transported to the location of the event).

输入格式

The first line contains an integer tt ( 1t3001 \le t \le 300 ) — the number of test cases.

Each test case starts with a line containing four integers n,m,x,yn, m, x, y ( 0n,m,x,y3000 \le n, m, x, y \le 300 ; n+m>0n+m>0 , x+y>0x + y > 0 ) — the number of lectures, the number of seminars, the number of HD projectors and the number of ordinary projectors, respectively.

The next nn lines describe lectures. Each line contains two integers aia_i , bib_i ( 1ai<bi1061 \le a_i < b_i \le 10^6 ) — the start time (inclusive) and finish time (exclusive) of the ii -th lecture.

The next mm lines describe seminars. Each line contains two integers pjp_j , qjq_j ( 1pj<qj1061 \le p_j < q_j \le 10^6 ) — the start time (inclusive) and finish time (exclusive) of the jj -th seminar.

输出格式

For each test case, print YES if it is possible to distribute projectors in order to meet all requirements, or NO otherwise.

In case of positive answer, output one additional line containing n+mn + m integers. The first nn integers should be not less than 11 and not greater than xx , and the ii -th of them should be the index of HD projector used in the ii -th lecture. The last mm integers should be not less than 11 and not greater than x+yx + y , and the jj -th of them should be the index of projector used in the jj -th seminar. If there are multiple answers, print any of them.

输入输出样例

  • 输入#1

    2
    2 2 2 2
    1 5
    2 5
    1 5
    1 4
    2 0 2 10
    1 3
    1 3
    

    输出#1

    YES
    2 1 4 3 
    YES
    2 1 
    
  • 输入#2

    3
    1 2 1 1
    3 4
    2 4
    1 3
    3 4 2 3
    5 7
    1 3
    1 7
    4 8
    2 5
    1 6
    2 8
    0 1 1 0
    1 1000000
    

    输出#2

    YES
    1 2 1 
    NO
    YES
    1 
    
首页