CF1215F.Radio Stations

省选/NOI-

通过率:0%

时间限制:7.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

In addition to complaints about lighting, a lot of complaints about insufficient radio signal covering has been received by Bertown city hall recently. nn complaints were sent to the mayor, all of which are suspiciosly similar to each other: in the ii-th complaint, one of the radio fans has mentioned that the signals of two radio stations xix_i and yiy_i are not covering some parts of the city, and demanded that the signal of at least one of these stations can be received in the whole city.

Of cousre, the mayor of Bertown is currently working to satisfy these complaints. A new radio tower has been installed in Bertown, it can transmit a signal with any integer power from 11 to MM (let's denote the signal power as ff). The mayor has decided that he will choose a set of radio stations and establish a contract with every chosen station. To establish a contract with the ii-th station, the following conditions should be met:

  • the signal power ff should be not less than lil_i, otherwise the signal of the ii-th station won't cover the whole city;
  • the signal power ff should be not greater than rir_i, otherwise the signal will be received by the residents of other towns which haven't established a contract with the ii-th station.

All this information was already enough for the mayor to realise that choosing the stations is hard. But after consulting with specialists, he learned that some stations the signals of some stations may interfere with each other: there are mm pairs of stations (uiu_i, viv_i) that use the same signal frequencies, and for each such pair it is impossible to establish contracts with both stations. If stations xx and yy use the same frequencies, and yy and zz use the same frequencies, it does not imply that xx and zz use the same frequencies.

The mayor finds it really hard to analyze this situation, so he hired you to help him. You have to choose signal power ff and a set of stations to establish contracts with such that:

  • all complaints are satisfied (formally, for every i∈[1,n]i \in [1, n] the city establishes a contract either with station xix_i, or with station yiy_i);
  • no two chosen stations interfere with each other (formally, for every i∈[1,m]i \in [1, m] the city does not establish a contract either with station uiu_i, or with station viv_i);
  • for each chosen station, the conditions on signal power are met (formally, for each chosen station ii the condition li≤f≤ril_i \le f \le r_i is met).

除了关于照明的投诉外,伯特城市政厅最近还收到了大量关于无线电信号覆盖不足的投诉。共有 nn 条投诉提交给了市长,这些投诉彼此之间 suspiciously 相似:在第 ii 条投诉中,某位无线电爱好者指出,两个广播电台 xix_i 和 yiy_i 的信号未能覆盖城市的某些区域,并要求至少其中一个电台的信号能在全城范围内被接收到。

当然,伯特城市长正努力满足这些投诉。一座新的无线电发射塔已在伯特城建成,它可发射任意整数功率 ff 的信号,其中 ff 的取值范围为 11 到 MM(我们记该信号功率为 ff)。市长决定选择一组广播电台,并与每个被选中的电台签订合同。要与第 ii 个电台签订合同,必须满足以下条件:

  • 信号功率 ff 不得小于 lil_i,否则第 ii 个电台的信号将无法覆盖全城;
  • 信号功率 ff 不得大于 rir_i,否则该电台的信号将被其他未与之签约的城镇居民接收到。

以上信息已足以让市长意识到选择电台是一项困难的任务。但在咨询专家后,他进一步了解到:某些电台之间可能存在信号干扰——存在 mm 对电台 (ui,vi)(u_i, v_i) 使用相同的信号频率;对于每一对这样的电台,不可能同时与二者签订合同。注意:若电台 xx 和 yy 使用相同频率,且 yy 和 zz 使用相同频率,这并不意味着 xx 和 zz 也使用相同频率。

市长发现分析这一情况极为困难,因此聘请了你来协助他。你需要选择一个信号功率 ff 以及一组拟签约的电台,使得满足以下全部条件:

  • 所有投诉均被满足(形式化地,对每个 i∈[1,n]i \in [1, n],城市必须与电台 xix_i 或电台 yiy_i 中至少一个签订合同);
  • 任意两个被选中的电台之间不互相干扰(形式化地,对每个 i∈[1,m]i \in [1, m],城市不得同时与电台 uiu_i 和 viv_i 签订合同);
  • 对每个被选中的电台 ii,其关于信号功率的约束均被满足(形式化地,对每个被选中的电台 ii,均有 li≤f≤ril_i \le f \le r_i)。

输入格式

The first line contains 44 integers nn, pp, MM and mm (2≤n,p,M,m≤4⋅1052 \le n, p, M, m \le 4 \cdot 10^5) — the number of complaints, the number of radio stations, maximum signal power and the number of interfering pairs, respectively.

Then nn lines follow, which describe the complains. Each line contains two integers xix_i and yiy_i (1≤xi<yi≤p1 \le x_i \lt y_i \le p) — the indices of the radio stations mentioned in the ii-th complaint). All complaints are distinct.

Then pp lines follow, which describe the radio stations. Each line contains two integers lil_i and rir_i (1≤li≤ri≤M1 \le l_i \le r_i \le M) — the constrains on signal power that should be satisfied if the city establishes a contract with the ii-th station.

Then mm lines follow, which describe the pairs of interfering radio stations. Each line contains two integers uiu_i and viv_i (1≤ui<vi≤p1 \le u_i \lt v_i \le p) — the indices of interfering radio stations. All these pairs are distinct.

第一行包含 44 个整数 nn、pp、MM 和 mm(2≤n,p,M,m≤4⋅1052 \le n, p, M, m \le 4 \cdot 10^5),分别表示投诉数量、广播电台数量、最大信号功率以及干扰电台对的数量。

接下来是 nn 行,描述各项投诉。每行包含两个整数 xix_i 和 yiy_i(1≤xi<yi≤p1 \le x_i \lt y_i \le p),表示第 ii 项投诉中所提及的广播电台的编号。所有投诉互不相同。

接下来是 pp 行,描述各广播电台。每行包含两个整数 lil_i 和 rir_i(1≤li≤ri≤M1 \le l_i \le r_i \le M),表示若城市与第 ii 个电台签订合同,则其信号功率必须满足的约束范围。

接下来是 mm 行,描述相互干扰的广播电台对。每行包含两个整数 uiu_i 和 viv_i(1≤ui<vi≤p1 \le u_i \lt v_i \le p),表示相互干扰的广播电台的编号。所有此类电台对互不相同。

输出格式

If it is impossible to choose signal power and a set of stations to meet all conditions, print −1-1.

Otherwise print two integers kk and ff in the first line — the number of stations in the chosen set and the chosen signal power, respectively. In the second line print kk distinct integers from 11 to pp — the indices of stations to establish contracts with (in any order). If there are multiple answers, print any of them; you don't have to minimize/maximize the number of chosen stations, and the same applies to signal power.

如果无法选择信号功率和一组基站来满足所有条件,则输出 −1-1。

否则,在第一行输出两个整数 kk 和 ff —— 分别表示所选基站的数量和所选的信号功率。在第二行输出 kk 个互不相同的、取值范围为 11 到 pp 的整数 —— 表示需签订合同的基站编号(顺序任意)。若存在多个可行解,输出任意一个即可;无需最小化或最大化所选基站的数量,对信号功率亦同理。

输入输出样例

  • 输入#1

    2 4 4 2
    1 3
    2 3
    1 4
    1 2
    3 4
    1 4
    1 2
    3 4

    输出#1

    2 3
    1 3
  • 输入#2

    2 4 4 2
    1 3
    2 4
    1 2
    1 2
    3 4
    3 4
    1 2
    3 4

    输出#2

    -1

输入解题思路,AI测评打分。不知道怎么写?

首页