#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 NN intersections (numbered from 11 to NN) and MM roads (numbered from 11 to MM). 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 S,s1,s2,,sk,SS, s_1, s_2, \ldots, s_k, S (where kk is even), such that there is a road directly connecting SS and s1s_1, sks_k and SS, and for all 1<ik1 \lt i \leq k, there is a road directly connecting si1s_{i-1} and sis_i.

However, the police control some streets in the city. On day ii, the police control all streets with indices in the range [li,ri][l_i, r_i], 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 QQ days. Now he wants to know on which days his evil plan can be carried out.

Input Format

The first line contains three integers N,M,QN, M, Q.

The next MM lines each contain two integers u,vu, v (guaranteed uvu \neq v), describing street number ii. It connects intersections uu and vv. It is guaranteed that there is at most one street between any pair of intersections.

The next QQ lines each contain two integers li,ril_i, r_i, meaning that on day ii the police will control all streets with indices in the range [li,ri][l_i, r_i].

Output Format

Output QQ lines.

On line ii, if on day ii 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: 1N,M,Q2×1051 \leq N, M, Q \leq 2 \times 10^5.

  • Subtask 1 (6 points): 1N,M,Q2001 \leq N, M, Q \leq 200.
  • Subtask 2 (8 points): 1N,M,Q2×1031 \leq N, M, Q \leq 2 \times 10^3.
  • Subtask 3 (25 points): i[1,Q]\forall i \in [1, Q], li=1l_i = 1.
  • Subtask 4 (10 points): i[1,Q]\forall i \in [1, Q], li200l_i \leq 200.
  • Subtask 5 (22 points): Q2×103Q \leq 2 \times 10^3.
  • Subtask 6 (29 points): No special constraints.

Translated by ChatGPT 5