11494 - Set operations   

Description

假設有A B C 3個set,range_diff A C的結果是

  • A與B做difference,得到D
  • 將D與C做difference,得到range_diff A C的結果

lower_bound and upper_bound can help you.

Input

How to compare the integer sequence (calculate the key of an integer sequence):

  • key=sum every elements in an integer sequence
  • if the length of a integer sequence is 0, the key is 0.
  • e.g., the key of an integer sequence "3 9 -1 3 -6" is 8 (3+9-1+3-6).

The input consist of series of command. Each commands is insert, range_diff, range_inter or range_out.

​insert: inserts an integer sequence (each value is greater than -11 and smaller than 11, stop reading from cin when value is 0). If a key has already existed, then replace it with the input sequence.

For example,

insert 3 9 -1 3 -6 0

The set should contain 3 9 -1 3 -6.

insert 2 2 -3 7 0

The set should contain 2 2 -3 7.

 

range_diff: calculates difference of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the difference. Note: What is the difference between set_difference and set_symmetric_difference? Warning: You must calculate from smaller key to bigger key.

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -8 9

It should output

-5 3 10 

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -8 16

It should output

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -5 16

It should output

-5 -5 

 

range_inter: calculates intersection of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the intersection.

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_inter -8 16

It should output

-5 2 


range_out: outputs all integer sequences from an integer (first key) to an integer (second key). Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing all elements of a key. Do not print anything if first key equals to second key.

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

range_out -7 12

It should output

3 9 -1 3 -6 

Output

Complete insert, range_diff, range_inter and range_out.

Sample Input  Download

Sample Output  Download

Tags




Discuss