#K841. Firewall Rule Conflict Checker
Firewall Rule Conflict Checker
Firewall Rule Conflict Checker
You are given a set of existing firewall rules and a new firewall rule. Each rule is defined by an interval, represented by two integers: the start and the end of the range. Two intervals conflict if they overlap, i.e. if the intersection of the intervals is non-empty (with the condition expressed in \( \text{max}(a, x) < \text{min}(b, y) \) in \( \LaTeX \) format).
The task is to determine if the new rule conflicts with any of the existing rules. If there is an overlap with any rule, print "Conflict"; otherwise, print "No Conflict".
Note: Two intervals that touch at the boundary (for example, end of one equals the start of the other) do not conflict.
inputFormat
The input is given via stdin and is in the following format:
n a1 b1 ... an bn x y
Where:
n
is a positive integer representing the number of existing firewall rules.- Each of the next
n
lines contains two integersai
andbi
(withai < bi
), representing the start and end of an existing rule. - The last line contains two integers
x
andy
(withx < y
), representing the new firewall rule.
outputFormat
Output a single line to stdout which is either:
Conflict
if the new rule overlaps with at least one existing rule, orNo Conflict
if it does not overlap with any rules.
3
1 5
8 10
15 20
4 9
Conflict