CF1250K.Projectors
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n lectures and m seminars to be conducted today at the Faculty of Approximate Sciences. The i-th lecture starts at ai and ends at bi (formally, time of the lecture spans an interval [ai,bi), the right bound is exclusive). The j-th seminar starts at pj and ends at qj (similarly, time of the seminar spans an interval [pj,qj), the right bound is exclusive).
There are x HD-projectors numbered from 1 to x and y ordinary projectors numbered from x+1 to x+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).
今天,近似科学学院需举办 n 场讲座和 m 场研讨会。第 i 场讲座的开始时间为 ai,结束时间为 bi(形式上,该讲座的时间区间为 [ai,bi),右端点不包含在内)。第 j 场研讨会的开始时间为 pj,结束时间为 qj(同理,该研讨会的时间区间为 [pj,qj),右端点不包含在内)。
学院共有 x 台高清投影仪,编号为 1 至 x;另有 y 台普通投影仪,编号为 x+1 至 x+y。投影仪需按如下规则分配:
- 每场讲座必须使用一台高清投影仪;
- 每场研讨会需使用一台投影仪(高清或普通均可);
- 在同一时刻,一台投影仪(高清或普通)最多只能用于一个活动;
- 若某台投影仪被分配给某个活动,则它必须全程用于该活动;
- 一台投影仪可在后续活动中重复使用,前提是该后续活动的开始时间不早于当前活动的结束时间。
请判断是否存在满足上述条件的投影仪分配方案;若存在,请给出一种方案。
再次注意:活动时间区间的右端点不包含在内。若某活动的开始时间恰好等于另一活动的结束时间,则投影仪可被复用(假设其可瞬间转移至该活动所在地点)。
输入格式
The first line contains an integer t (1≤t≤300) — the number of test cases.
Each test case starts with a line containing four integers n,m,x,y (0≤n,m,x,y≤300; n+m>0, x+y>0) — the number of lectures, the number of seminars, the number of HD projectors and the number of ordinary projectors, respectively.
The next n lines describe lectures. Each line contains two integers ai, bi (1≤ai<bi≤106) — the start time (inclusive) and finish time (exclusive) of the i-th lecture.
The next m lines describe seminars. Each line contains two integers pj, qj (1≤pj<qj≤106) — the start time (inclusive) and finish time (exclusive) of the j-th seminar.
第一行包含一个整数 t(1≤t≤300)—— 表示测试用例的数量。
每个测试用例以一行开始,该行包含四个整数 n,m,x,y(0≤n,m,x,y≤300;n+m>0,x+y>0)—— 分别表示讲座的数量、研讨会的数量、高清投影仪的数量以及普通投影仪的数量。
接下来的 n 行描述讲座。每行包含两个整数 ai、bi(1≤ai<bi≤106)—— 表示第 i 个讲座的开始时间(包含)和结束时间(不包含)。
接下来的 m 行描述研讨会。每行包含两个整数 pj、qj(1≤pj<qj≤106)—— 表示第 j 个研讨会的开始时间(包含)和结束时间(不包含)。
输出格式
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+m integers. The first n integers should be not less than 1 and not greater than x, and the i-th of them should be the index of HD projector used in the i-th lecture. The last m integers should be not less than 1 and not greater than x+y, and the j-th of them should be the index of projector used in the j-th seminar. If there are multiple answers, print any of them.
对于每个测试用例,如果能够分配投影仪以满足所有要求,则输出 YES;否则输出 NO。
若答案为 YES,则额外输出一行,包含 n+m 个整数。前 n 个整数应不小于 1 且不大于 x,其中第 i 个整数表示第 i 场讲座所使用的高清投影仪的编号。后 m 个整数应不小于 1 且不大于 x+y,其中第 j 个整数表示第 j 场研讨课所使用的投影仪的编号。若存在多种可行方案,输出任意一种即可。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?