Submit | All submissions | Best solutions | Back to list |
HS08SE - Subset or Element |
Given two sets A and B decide which of the following cases is satisfied.
- A is an element and a subset of B;
- A is an element but not a subset of B;
- A is a subset but not an element of B;
- A is neither an element nor a subset of B.
Sets are given by the sequence of commas, curly brackets, and E (denoting the empty set) symbols. Length of the set description does not exceed 100000 characters.
Input
First t, the number of test cases. In the following 2t lines description of set pairs, each set in the separate line in the same format as presented in the examples below.
Output
For each pair of sets output one number coresponding to the case described above.
Example 1
Input: 2 A = {E} B = {{E}} A = {E} B = {{{E}}} Output: 2 4
Comment: In the above examples A is a set containing one element: an empty set. In the first example A is an element of B, which is a set containing one element: a set containing one element: an empty set. In the second example B is also a a set containing one element, but its element is not the A set but, a set containing A as an element.
Example 2
Input: 5 A = {E} B = {E,{{E}}} A = {E} B = {E,{E}} A = {{{E}}} B = {{E,E},{E,{E}},{E}} A = {{E,{E}}} B = {{E,E},{E,{E}},{E}} A = {E} B = {{E},E} Output: 3 1 4 3 1
Example 3
Input: 1 A = {{E},E,E,E} B = {{E,E},E,E,E,E,E,{{{E,{{E,{E},{E,E},{{{E,{{E,E}},E}}}}}}}}} Output: 3
Comment: Please note, that an element of a set might be listed multiple times, what does not mean, that the set contains more than one copy of that element.
Scoring
For solving this problem you will score 10 points.
Added by: | kuszi |
Date: | 2009-01-19 |
Time limit: | 0.200s-0.600s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE |
Resource: | Problem originally posted by Robert Janczewski |