Page 2 of 11
727
Posted: Fri Mar 28, 2003 5:01 pm
by Hisoka
Help, I try all sample I/O in that board, I pass all, but I always got WA too.
Can you give me more test to check my program, or you give me hint??

Posted: Tue Apr 01, 2003 1:15 pm
by Hisoka
may there are negatif input for this problem?
like this:
input = -1+2
output= 1-2+

Posted: Tue Apr 01, 2003 2:35 pm
by turuthok
Hello Hisoka, ... There will be no negative number. Each line in one test-case will only have 1 char.
Did you notice that this problem has multiple-input format ?
Try these test-cases:
Input
Code: Select all
7
1
+
2
-
3
1
+
2
*
3
(
1
+
2
)
/
(
3
-
4
)
(
(
1
+
2
)
*
(
3
-
4
)
+
5
)
/
(
6
+
7
)
(
1
*
(
2
+
3
+
(
4
*
5
)
)
+
1
)
(
(
(
1
)
)
)
1
Output
Code: Select all
12+3-
123*+
12+34-/
12+34-*5+67+/
123+45*+*1+
1
1
Good luck,
-turuthok-
Posted: Tue Apr 01, 2003 7:18 pm
by Hisoka
Hello turuthok, I pass for all your sample I/O with my program when I got WA. And my program is multiple input too.

Posted: Wed Apr 02, 2003 8:20 am
by Dominik Michniewski
I got the same problem with this question. I use simple expression's parser to create postfix notation.
I pass tests from you, turothok, and also pass tests given in other threads by Ivan Golubev
Maybe I miss something ? Please help, because problem seems to be easy ...
Dominik Michniewski
Posted: Wed Apr 02, 2003 12:34 pm
by Hisoka
I got AC now, thanx turuthok
to dominik:
I try your program from your previous post, I got this.
you always got Wrong answer when your first input. but you get true output for your next output. so I think your mistake only from your I/O, not your algo.

Posted: Fri Apr 18, 2003 8:25 pm
by little joey
Well, I'm getting sick & tired of this problem. I struggled with it 9 months ago, and I'm stil struggling with it now.
Can anybody, once and for all, put into plain english what is wrong with the input to this problem and how we are supposed to deal with it. I'm shure I handle all the cases in all the threads properly, but WA is all I get.
Why don't the judges correct a problem that is so long known to exist?
HELP ME, please...
Posted: Sat Apr 19, 2003 6:19 am
by Andrey Mokhov
Hello, everyone!
In fact I might be a lucky person as I got AC on the problem after my first submission.
Firstly I want to say that I didn't handle cases all you talking about :
I guess there is no expressions where two operands have no operator between.
To get the postfix notation I use simple stack method and it works.
Anyway I'm not sure that the judge data is correct but my AC says me that there can be two cases:
- Judge is right.
- Judge and me are
equally wrong.
I guess the first is more possible than the second.
Good luck!
Andrey.
Posted: Sat Apr 19, 2003 6:44 am
by ..
No,
I have submitted my test program again, and find that the judge input isn't corrected yet.
Actuallly it is possible to get accepted w/o specially handled the incorrect input, if you are lucky enough that your program can output the same thing as the sample output.
Posted: Sat Apr 19, 2003 10:24 am
by little joey
I hate it, but I'll add my code to the long list of published sources on this matter. It's a plain vanilla implementation of a RDP without any syntax checking. It glues together all expressions in one case, like Ivan Golubjev suggested, so it can handle cases like
Code: Select all
(1+2)3 -> 12+3
12 -> 12
1(7*8)6 -> 178*6
etc.
Please give me some feedback.
[pascal]program p727;
var
infix,postfix:ansistring;
parsepos,writepos:integer;
procedure expression;forward;
procedure factor;
begin
case infix[parsepos] of
'0'..'9':begin
inc(writepos);
postfix[writepos]:=infix[parsepos];
inc(parsepos);
end;
'(':begin
inc(parsepos);
expression;
inc(parsepos); //eat ')'
end;
end;
end;
{
ALL BUT THE CRITICAL SECTION REMOVED,
SINCE IT'S A SPOILER

}
[/pascal]
Posted: Sat Apr 19, 2003 11:18 am
by Ivan Golubev
Here this a part from my code:[c]void getexpression(void);
void getfact(void)
{
if (*st == '(') {
st++;
getexpression();
assert(*st == ')');
st++;
if (isdigit(*st)) {
printf("%c", *st);
st++;
}
return;
}
while (isdigit(*st)) {
printf("%c", *st);
st++;
}
}[/c]
The fix itself here is:[c] if (isdigit(*st)) {
printf("%c", *st);
st++;
}[/c]
With this modification I've got accepted.
Posted: Sat Apr 19, 2003 11:55 am
by little joey
Thanks man!!!
That did it. Finaly got AC.
I'm not shure, but I think reading more than one digit in getfact() could be essential too.
Hope to help you back someday,
-little joey
727
Posted: Sat Apr 19, 2003 5:58 pm
by Farid Ahmadov
I know that there is an input here like:
1(2+4)3 or 1*2(1+2)1+2
I have checked it many times
I guess that it means that there is not only one input, but more than one...
I think the answers are:
124+3 and 12*12+12+
I ask ones who solved this problem and got AC.
Please explain it if you can
Posted: Sun Apr 20, 2003 10:23 pm
by little joey
The answer is in the previous thread; especialy the answer Ivan Golubev gave to my question. I added two 'features' to my code:
1. Read all occurring digits and print them, even if you expect only one;
2. Read any digit that follows a closing bracket and print it.
This means that for the input
12+3
I print
123+
and for the input
(1+2)3
I print
12+3
and finally got AC.
727
Posted: Thu Jan 29, 2004 10:59 am
by Zhao Le
I know and I also hate to post my code here.
BUT I don't know how to get rid of Runtime ERROR(SISIGIV)
The code is deleted.