551  Nesting a Bunch of Brackets
Moderator: Board moderators
Not Specified
Hi Sohel,
I think the above sample inputs and outputs are not wrong as I got accepted with this inputs and outputs. You said,
Mahmud
I think the above sample inputs and outputs are not wrong as I got accepted with this inputs and outputs. You said,
But, I think, here () is followed by a separate character * and this sequence is followed by another ().As () is a correct sequence so, I think, ()*() should give positive answer. After all I got accepted in this way.()*()
this should give a negative result but your one doesn't;
the corresponding closing of the first should be the last.
Mahmud
Hi,
I'm getting WA for this problem.
Can someone explain me why these 2 inputs give different outputs.
((**)()a+b)[(a){a+n}](*
((**)()a+b)[(a){a+n}](
And I'm not sure what this statement means?
"If the expression is not properly nested your program should determine the position of the offending bracket, that is the length of the shortest prefix of the expression that can not be extended to a properly nested expression."
Thanx,
angga888
I'm getting WA for this problem.
Can someone explain me why these 2 inputs give different outputs.
((**)()a+b)[(a){a+n}](*
((**)()a+b)[(a){a+n}](
And I'm not sure what this statement means?
"If the expression is not properly nested your program should determine the position of the offending bracket, that is the length of the shortest prefix of the expression that can not be extended to a properly nested expression."
Thanx,
angga888
don't think so
Hi again,
my AC program gives the same output..... very strange.
eg. ())[]9()909
it will be impossible for a valid combination to emerge after the third bracket ..).. therefore this particular one is the offending one.
Hope it helps.
How do you know these two inputs give two different outputs((**)()a+b)[(a){a+n}](*
((**)()a+b)[(a){a+n}](
my AC program gives the same output..... very strange.
this is actually the first bracket (from left) that is out of position.And I'm not sure what this statement means?
"If the expression is not properly nested your program should determine the position of the offending bracket, that is the length of the shortest prefix of the expression that can not be extended to a properly nested expression."
eg. ())[]9()909
it will be impossible for a valid combination to emerge after the third bracket ..).. therefore this particular one is the offending one.
Hope it helps.
Not specified
Hi:
Sohel is correct.
Here, '(*' has to be considered as different characters
as '(*' is not completed and they are the last two characters in
that sequence.
((**)()a+b)[(a){a+n}](*
Sohel is correct.
Here, '(*' has to be considered as different characters
as '(*' is not completed and they are the last two characters in
that sequence.
((**)()a+b)[(a){a+n}](*
When I get a WA in the problem, then I check out some help for me and I test the sample input given by Mahmud776. I was mad with his sample input because I fail to match with his output. But those are output from his AC code. So I was not confident to say his output was wrong.
But finally understanding the problem properly I get AC and find that his output was wrong. I think Judge Data is not strong enough to test the solution of problem. Though I think the problem was little confusing because it ask for the minimum prefix which can't extended as correct one.
For example:
()()(a+b)(
Output for it: NO 11
But that expration can be extended as correct one like; ()()(a+b)()
So output should be 'YES' rather 'NO 11'
But finally understanding the problem properly I get AC and find that his output was wrong. I think Judge Data is not strong enough to test the solution of problem. Though I think the problem was little confusing because it ask for the minimum prefix which can't extended as correct one.
For example:
()()(a+b)(
Output for it: NO 11
But that expration can be extended as correct one like; ()()(a+b)()
So output should be 'YES' rather 'NO 11'
551
Hi:
Can anyone help me?
I only need the outputs for this inputs, or others inputs/outputs with some special cases.
Thanks!
Input:
(*adf(y)(*
(*adf(y)(
(a*)
)()
*)()
ads()asdf
(***)
(**
({{]}]
(**){*{]}]
<><
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)>
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)><
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)>(*
[**
((((())
(*(*(*(**)*)
(**********(
(*a++(*)
(*a{+}*)
(*)
(**)
((**))
((()))
{}{}{}{}{}{}{}{}{
{{{}[()((**))][][]}}
(())))
(***)
{*(())(()*)*}
{adfadf[adfadf(adfa(*adfadf*)adfaf)(*afdsf*)]adfadf}
(AADFASDFADSF)
Can anyone help me?
I only need the outputs for this inputs, or others inputs/outputs with some special cases.
Thanks!
Input:
(*adf(y)(*
(*adf(y)(
(a*)
)()
*)()
ads()asdf
(***)
(**
({{]}]
(**){*{]}]
<><
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)>
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)><
<sgf(sfg[sfg{sfg(*sfgsdfg*)dhj}]dfh)>(*
[**
((((())
(*(*(*(**)*)
(**********(
(*a++(*)
(*a{+}*)
(*)
(**)
((**))
((()))
{}{}{}{}{}{}{}{}{
{{{}[()((**))][][]}}
(())))
(***)
{*(())(()*)*}
{adfadf[adfadf(adfa(*adfadf*)adfaf)(*afdsf*)]adfadf}
(AADFASDFADSF)

 Experienced poster
 Posts: 106
 Joined: Thu Jan 29, 2004 12:07 pm
 Location: Bangladesh
 Contact:
Dear Mahmud776,
one of the sample cases you have posted here is wrong. for the input
you said the output is
which is wrong. my AC code gives output
I guess this is a silly typo. Again, for the case
I considered the last '(*' as one symbol and that is what one is supposed to for all the cases in this problem.
one of the sample cases you have posted here is wrong. for the input
Code: Select all
((**)()a+b)[(a){a+n}](
Code: Select all
NO 20
Code: Select all
NO 21
Code: Select all
((**)()a+b)[(a){a+n}](*
Apparently the output logic of this problem is quite arguable.
I tend to agree with Rajib's theory that for
cases like
the output should be
because strings of this kind can be extended so that they
represents a valid bracketing ( a valid expression ).
I mean they have no prefix for which no extension is possible.
Anyway. Apparently there's some mess about this problem.
But I doubt the Judge's tests follow this
logic ( Rajib's theory ).
I found another thread where there's sufficient I/O.
http://onlinejudge.uva.es/board/viewtopic.php?t=6724
jagadish has posted some output there which
is quite close to mine although it differs in some cases.
We differ in the following test cases:
input
my output
his output
It would be nice if someone having ACC program could
verify and say which one of these outputs is correct. I hope
he/she won't come up with a new theory about
how a correct answer should look like
I tend to agree with Rajib's theory that for
cases like
Code: Select all
()()(a+b)(
Code: Select all
YES
represents a valid bracketing ( a valid expression ).
I mean they have no prefix for which no extension is possible.
Anyway. Apparently there's some mess about this problem.
But I doubt the Judge's tests follow this
logic ( Rajib's theory ).
I found another thread where there's sufficient I/O.
http://onlinejudge.uva.es/board/viewtopic.php?t=6724
jagadish has posted some output there which
is quite close to mine although it differs in some cases.
We differ in the following test cases:
input
Code: Select all
[**
((((())
(*(*(*(**)*)
Code: Select all
NO 2
NO 4
NO 3
Code: Select all
No 4
No 8
No 7
verify and say which one of these outputs is correct. I hope
he/she won't come up with a new theory about
how a correct answer should look like
Can someone explain these outputs
Output
for the following
Input
My WA program currently prints
Output
for that sample input.
Could someone explain if/why my output is wrong
and if/why the first output ( from jagadish ) is OK ?
These are the only test cases in which my Output differs
from jagadish's Output for his sample Input ( see above ).
I have made also a post in
http://onlinejudge.uva.es/board/viewtopic.php?t=4897
but that thread is even more confusing. The theory of Rajib
seems reasonable to me but when I follow it the Judge still
gives me WA. Although I would say this interpretation is the
most correct one ( logically ).
Thanks in advance.
Any help is welcome.
Output
Code: Select all
No 3
No 4
No 8
No 7
Input
Code: Select all
(**
[**
((((())
(*(*(*(**)*)
My WA program currently prints
Output
Code: Select all
NO 2
NO 2
NO 4
NO 3
Could someone explain if/why my output is wrong
and if/why the first output ( from jagadish ) is OK ?
These are the only test cases in which my Output differs
from jagadish's Output for his sample Input ( see above ).
I have made also a post in
http://onlinejudge.uva.es/board/viewtopic.php?t=4897
but that thread is even more confusing. The theory of Rajib
seems reasonable to me but when I follow it the Judge still
gives me WA. Although I would say this interpretation is the
most correct one ( logically ).
Thanks in advance.
Any help is welcome.

 Experienced poster
 Posts: 106
 Joined: Thu Jan 29, 2004 12:07 pm
 Location: Bangladesh
 Contact: