10788 - Parenthesizing Palindromes

All about problems in Volume CVII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

10788 - Parenthesizing Palindromes

Hi,

The problem description says that the expression ``abbaddcc" has only one interpretation: ``(ab ba) (d d) (c c)". Is it true?
(a(bb)a)(dd)(cc) ?

Wojciech
w k
Learning poster

Posts: 74
Joined: Wed Apr 14, 2004 11:14 pm

Re: 10788

w k wrote:Hi,

The problem description says that the expression ``abbaddcc" has only one interpretation: ``(ab ba) (d d) (c c)". Is it true?
(a(bb)a)(dd)(cc) ?

Wojciech

In this problem, these two interpretations are considered to be the same. The problem statement is a little bit vague on what "interpretations" do we consider.

I offer my definition: for a string, an interpretation is a well-formed string of parenthesis of the same length, such that for each pair of parenthesis the corresponding two letters of the string are the same.

E.g. the string abbaddcc has only one interpretation:
Code: Select all
`abbaddcc(())()()`

misof
A great helper

Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Hi,

I believe Your definition is correct.
Is Your code AC?
If yes - they should change the problem description according to Your definition, I think.

Wojciech
w k
Learning poster

Posts: 74
Joined: Wed Apr 14, 2004 11:14 pm

Yes, my code is AC. But I think that my explanation gives away a little bit more than the author intended -- in other words, it pushes you in the right direction of thinking. And anyway, nobody has got the time to fix the problem statement. There are far worse problem statements out there that have to be fixed. And for minor details there is exactly this board.

misof
A great helper

Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Hmm... I admit that the statement is not that clear. Md Kamruzzaman, the author of the alternate solution for this problem, had pointed out this anomaly with the statement before it was used for the contest. But I was reluctant to make any change. Misof is right, if I were too specific then it would have given away much of the problem. It was not my intent.

I think I did mention these things in the form of an example in the problem statement. It worked fine for many. But that doesn't certify the problem statement to be clear. I am aware of that.

However, I am still against changing the problem statement. I hope the sufferers would take it lightly.

kmhasan
Problemsetter

Posts: 107
Joined: Fri Oct 26, 2001 2:00 am

Hi

I wonder if there are blank lines in the input? What is the expected output for those cases:
14
aaabba
aabb
bbababba

aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb
abcdefgabcdefg
accffbbaccxxpqqrrp
aa
a
aba
abba
dddddddddddddddddddd
ddddddddddddddddddddd

Is this right?
Case 1: Valid, Multiple
Case 2: Valid, Unique
Case 3: Invalid
Case 4: Valid, Unique
Case 5: Valid, Multiple
Case 6: Invalid
Case 7: Valid, Unique
Case 8: Valid, Unique
Case 9: Valid, Unique
Case 10: Invalid
Case 11: Invalid
Case 12: Valid, Multiple
Case 13: Valid, Multiple
Case 14: Invalid

Krzysztof Duleba
Guru

Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland

There is no empty string in the input because I use scanf("%s", s) and got AC.
And the output of your case 12(abba) should be "Valid, Unique".

Cho
A great helper

Posts: 274
Joined: Wed Oct 20, 2004 11:51 pm
Location: Hong Kong

How could it be that abba has only one interpretation? Can't we write it as (ab ba) or (a (b b) a)?

Krzysztof Duleba
Guru

Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland

Krzysztof Duleba wrote:How could it be that abba has only one interpretation? Can't we write it as (ab ba) or (a (b b) a)?

misof
A great helper

Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Yes, that should be helpful. Somehow I didn't notice your previous post - sorry.

Krzysztof Duleba
Guru

Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland

Can any one give me any Critical test case ?

Can any one give me any Critical test case ?
I am trying to solve this problem and getting WA again and again. I may miss some thing from the problem. Please give me some input and output so that I can fix my BUG

Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/
Niaz
Learning poster

Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh

Hi, are there any more test cases? I've tried the sample input and the test cases in this thread, but still can't get it accepted.
sq
New poster

Posts: 3
Joined: Sun Jan 02, 2005 9:15 am

Hi, try these important cases:

2
abckkkkkcba
abbkkbba

Case 1: Valid, Multiple
Case 2: Valid, Multiple

shamim
A great helper

Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Dhaka

Try this case, I used it to debug my program:

Code: Select all
`1abaaba`

Code: Select all
`Case 1: Valid, Unique`
stubbscroll
Experienced poster

Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway

shamim wrote:Hi, try these important cases:

2
abckkkkkcba
abbkkbba

Case 1: Valid, Multiple
Case 2: Valid, Multiple

Hi~ Shouldn't abckkkkkcba be Invalid? (It has a singled k)
sq
New poster

Posts: 3
Joined: Sun Jan 02, 2005 9:15 am

Next