首页 > ACM题库 > HDU-杭电 > hdu 2278 Tidy up the idioms待解决[解题报告]C++
2014
01-04

hdu 2278 Tidy up the idioms待解决[解题报告]C++

Tidy up the idioms

问题描述 :

Garfield enjoys learns idioms very much. There is an interesting kind of idiom of chinese, and we call it ”歇后语". Garfield has a list of this idioms, but the format is awful. Garfield is not very smart, you should use the program to help him to tidy up the idioms.
  The standard formt of an idiom here is “A――B”, for example, “王婆卖瓜――自卖自夸". But now there are three awful situations you need to deal with:
1)sometimes there is a pair of chinese brackets in the expression to explain something, and you need to omit the brackets and contexts between them. For example, “麦场上挂马灯――照常(场)".

2)sometimes there are several Bs for the unique A, and two Bs are separated by chinese semicolons. You need to slip the idiom, for each B. For example, “麻布手中绣牡丹――配不上;不配".

3)sometimes the dash between A and B is took place by chinese comma, and you need to change them into dash. For example, “泥菩萨过河,自身难保".

But sometimes both the dash and the comma exit in the idiom, then we define it that the dash is just the separator for A and B.

输入:

There is a integer N(1<N<10000) indicating the number of the list to deal. Then N lines follows, each line contain an idiom, and the length of every idiom isn’t beyond 200.

输出:

There is a integer N(1<N<10000) indicating the number of the list to deal. Then N lines follows, each line contain an idiom, and the length of every idiom isn’t beyond 200.

样例输入:

4
王婆卖瓜――自卖自夸
麦场上挂马灯――照常(场)
麻布手中绣牡丹――配不上;不配
泥菩萨过河,自身难保

样例输出:

5
麦场上挂马灯――照常
王婆卖瓜――自卖自夸
麻布手中绣牡丹――不配
泥菩萨过河――自身难保
麻布手中绣牡丹――配不上


  1. 我还有个问题想请教一下,就是感觉对于新手来说,递归理解起来有些困难,不知有没有什么好的方法或者什么好的建议?

  2. L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-1])这个地方也也有笔误
    应改为L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-2])

  3. A猴子认识的所有猴子和B猴子认识的所有猴子都能认识,这句话用《爱屋及乌》描述比较容易理解……