#P3225. 区间
区间
Description
LogLoader, Inc. is a company specialized in providing products for analyzing logs. While Ikki is working on graduation design, he is also engaged in an internship at LogLoader. Among his tasks, one is to write a module for manipulating time intervals, which have confused him a lot. Now he badly needs your help. In discrete mathematics, you have studied several basic set operations, namely union, intersection, relative complementation and symmetric difference, which naturally apply to the specialization of sets as intervals.. For your quick reference they are summarized in the table below: Definition Ikki has abstracted the interval operations emerging from his job as a tiny programming language. He wants you to implement an interpreter for him. The language maintains a set S, which starts out empty and is modified as specified by the following commands:Operation Notation Union A ∪ B {x : x ∈ A or x ∈ B} Intersection A ∩ B {x : x ∈ A and x ∈ B} Relative complementation A − B {x : x ∈ A but document.write(navigator.userAgent.indexOf("MSIE 6.0")!=-1?"not <i>x</i> ∈":"<i>x</i> ∉"); B} Symmetric difference A ⊕ B (A − B) ∪ (B − A) Command Semantics U T S ← S ∪ T I T S ← S ∩ T D T S ← S − T C T S ← T − S S T S ← S ⊕ T
Input
The input contains exactly one test case, which consists of between 0 and 65,535 (inclusive) commands of the language. Each command occupies a single line and appears like where End of file (EOF) indicates the end of input.X
TX
is one of ‘U
’, ‘I
’, ‘D
’, ‘C
’ and ‘S
’ and T is an interval in one of the forms (
a,
b)
, (
a,
b]
, [
a,
b)
and [
a,
b]
(a, b ∈ Z, 0 ≤ a ≤ b ≤ 65,535), which take their usual meanings. The commands are executed in the order they appear in the input.
Output
Output the set S as it is after the last command is executed as the union of a minimal collection of disjoint intervals. The intervals should be printed on one line separated by single spaces and appear in increasing order of their endpoints. If S is empty, just print “empty set
” and nothing else.
U [1,5]
D [3,3]
S [2,4]
C (1,5)
I (2,3]
(2,3)
Source
PKU Local 2007 (POJ Monthly--2007.04.28), frkstyc