<PREV Problem:
NEXT>
Solved by 2979 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Set Intersection

Time limit = 5 second(s)

Memory limit = 33000 Kb

Your task is to find the intersection of two sets of positive integers.

Input The input consists of two sets of positive integers A={a1, a2, ..., an} and B={b1, b2, ..., bk} represented as two whitespace-separated lists of numbers. Each list ends with -1, that serves as an end-of-set marker. Repetitions of elements are possible in the input, but not in the output. You may assume that 0 < ai, bi < 106 and that the sets A and B are of size less than 1000.

Output is list of numbers or word "empty" if intersection is empty.

Input#1
6 7 8 1 2 3 -1
4 3 2 1 1 -1
Output#1
1 2 3
Input#2
1 2 3 -1
4 4 5 5 6 6 -1
Output#2
empty

Author:
Voroztsov Artem

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 220ms

SW soft NIX
ID = 54.224.18.114