#P6684. [BalticOI 2020] 小丑 (Day1)
[BalticOI 2020] 小丑 (Day1)
Description
The Clown has returned to Gotham City and is ready to carry out an evil plan. Gotham City has intersections (numbered from to ) and roads (numbered from to ). Each road connects two different intersections, and there is at most one road between any pair of intersections.
To carry out his evil plan, the Clown needs to walk through an odd cycle in the city. Formally, an odd cycle is a sequence of the form (where is even), such that there is a road directly connecting and , and , and for all , there is a road directly connecting and .
However, the police control some streets in the city. On day , the police control all streets with indices in the range , and the Clown cannot use these streets. By bribing an insider in the police department, the Clown has learned the police plan for controlling streets over the next days. Now he wants to know on which days his evil plan can be carried out.
Input Format
The first line contains three integers .
The next lines each contain two integers (guaranteed ), describing street number . It connects intersections and . It is guaranteed that there is at most one street between any pair of intersections.
The next lines each contain two integers , meaning that on day the police will control all streets with indices in the range .
Output Format
Output lines.
On line , if on day the Clown's plan can be carried out, output YES; otherwise output NO.
6 8 2
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
4 8
4 7
NO
YES
Hint
Sample Explanation

Subtasks
All testdata satisfy: .
- Subtask 1 (6 points): .
- Subtask 2 (8 points): .
- Subtask 3 (25 points): , .
- Subtask 4 (10 points): , .
- Subtask 5 (22 points): .
- Subtask 6 (29 points): No special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号