F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

List Operations

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 625    Accepted Submission(s): 182


Problem Description
A list is a sequence of zero or more elements, expressed in this form: [a1, a2, a3, ... , an], where each ai is one or more consecutive digits or lowercase letters. i.e. each list begins with a left square bracket, then zero or more elements separated by a single comma, followed by a right square bracket. There will be no whitespace characters (spaces, TABs etc) within a list.

In this problem, we use two list operations: append (++) and remove (--).
1. A ++ B: append elements in B to the end of A.
2. A -- B: remove all the elements in B, from A. If something appears more than once in B, remove it that many times in A. If there are many equal elements in A to choose from, remove them from left to right (until all occurrences are removed, or there is no need to remove more elements).

Your task is to write a calculator, evaluating simple expressions or the form ˇ°list1 ++ list2ˇ± or ˇ°list1 -- list2ˇ±.
 

Input
There will be at most 10 expressions, one in each line, each having the form ˇ°list1 ++ list2ˇ± or ˇ°list1 -- list2ˇ±, with no more than 80 characters in total (not counting the newline character). There will be exactly two spaces in each line: one before and one after the operator. Input ends with a single dot. The input is guaranteed to satisfy the restrictions stated above
 

Output
For each expression, print its result on a single line.
 

Sample Input
[1,2,3] ++ [1,2,3] [a,b,c,t,d,e,t,x,y,t] -- [t] [a,b,c,t,d,e,t,x,y,t] -- [t,t,t,t] [123] ++ [456] .
 

Sample Output
[1,2,3,1,2,3] [a,b,c,d,e,t,x,y,t] [a,b,c,d,e,x,y] [123,456] 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:28:50, Gzip enabled