当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3242:List Operations

题目描述
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”.
输入解释
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
输出解释
For each expression, print its result on a single line.
输入样例
[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]
.
输出样例
[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
来自杭电HDUOJ的附加信息
Recommend zhonglihua

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3242

最后修改于 2020-10-25T23:01:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)