#SRD0000085. Joker (Joker)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Joker (Joker)
Joker
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a simple undirected graph with vertices numbered from 1 to and edges numbered in input order. Every edge joins distinct vertices, and no unordered pair occurs more than once. On day , the edges indexed by the inclusive interval are monitored and cannot be used. Consider the graph formed by all remaining edges. Joker can carry out his plan if and only if this graph has an odd-length cycle. Decide this independently for every day; edge removal does not persist into later days.
Input
The first line contains . Each of the next lines contains the endpoints of one indexed edge, followed by lines . All indices are 1-based.
Output
Print YES if the remaining graph contains an odd cycle, otherwise print NO, one answer per query.
Subtasks
-
Subtask 1 (6 points): ; ; . ; , ; no repeated edges; .
-
Subtask 2 (8 points): ; ; . ; , ; no repeated edges; .
-
Subtask 3 (25 points): ; ; . ; , ; no repeated edges; . for every query.
-
Subtask 4 (10 points): ; ; . ; , ; no repeated edges; . for every query.
-
Subtask 5 (22 points): ; ; . ; , ; no repeated edges; .
-
Subtask 6 (29 points): ; ; . ; , ; no repeated edges; .
Examples
Input
6 8 2
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
4 8
4 7
Output
NO
YES
Explanation
On the first day only edges 1 to 3 remain; the graph is bipartite, hence there is no odd cycle (NO). On the second day edges 4 to 7 are removed; remaining edges 1,2,3,8 include triangle , so the answer is YES.