CF1814F.Communication Towers
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n communication towers, numbered from 1 to n , and m bidirectional wires between them. Each tower has a certain set of frequencies that it accepts, the i -th of them accepts frequencies from li to ri .
Let's say that a tower b is accessible from a tower a , if there exists a frequency x and a sequence of towers a=v1,v2,…,vk=b , where consecutive towers in the sequence are directly connected by a wire, and each of them accepts frequency x . Note that accessibility is not transitive, i. e if b is accessible from a and c is accessible from b , then c may not be accessible from a .
Your task is to determine the towers that are accessible from the 1 -st tower.
输入格式
The first line contains two integers n and m ( 1≤n≤2⋅105 ; 0≤m≤4⋅105 ) — the number of communication towers and the number of wires, respectively.
Then n lines follows, the i -th of them contains two integers li and ri ( 1≤li≤ri≤2⋅105 ) — the boundaries of the acceptable frequencies for the i -th tower.
Then m lines follows, the i -th of them contains two integers vi and ui ( 1≤vi,ui≤n ; vi=ui ) — the i -th wire that connects towers vi and ui . There are no two wires connecting the same pair of towers.
输出格式
In a single line, print distinct integers from 1 to n in ascending order — the indices of the communication towers that are accessible from the 1 -st tower.
输入输出样例
输入#1
6 5 3 5 1 2 2 4 2 3 3 3 4 6 1 3 6 1 3 5 3 6 2 3
输出#1
1 3 5 6
输入#2
3 1 2 3 1 4 1 1 1 3
输出#2
1
输入#3
5 5 1 3 2 3 2 2 3 5 2 4 1 2 2 3 3 4 4 1 4 5
输出#3
1 2 3 4 5