|
|||||||||||||||||||
|
SPOJ time: 2012-05-26 13:53:01 |
Subset or ElementProblem code: HS08SE
Given two sets A and B decide which of the following cases is satisfied.
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. InputFirst 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. OutputFor 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. ScoringFor solving this problem you will score 10 points.
|
||||||||||||||||||
| |||||||||||||||||||