Page 1 of 2
10941 - Words adjustment
Posted: Sat Oct 15, 2005 9:31 pm
by Rostislav
In the input there is some word that's length is more than 1000 (even 1500)!
And I have a question, when I submit a code in C the reply is COMPILE ERROR, but in C++ MEMORY LIMIT or ACCEPTED(WA)
I mean than in C++ the source is being executed while in C it is not, because of memory shortage, why does this happens?
Rostislav
Posted: Sun Oct 16, 2005 1:06 am
by Jan
There are several functions that work in c++ compiler but not in c. I think you are using those types of function.
And there are some library files you cannot include in c. Like vector.h.
Posted: Sun Oct 16, 2005 8:39 am
by Rostislav
The code is the same and it is written only with C functions.
Posted: Sun Oct 16, 2005 9:09 am
by Jan
Can you show your code. Only the part which makes difference.
Posted: Sun Oct 16, 2005 11:33 am
by Rostislav
There is no difference, just submiting one and the same code
but once like C and once like C++.
Rostislav
Posted: Sun Oct 16, 2005 8:08 pm
by Per
Perhaps you declare variables in the middle of a code block?
E.g. "for (int i = ..."?
Posted: Sun Oct 16, 2005 10:27 pm
by Rostislav
I apologize, my mistake!
I had used inline function and my compilator doesn't give any error about that when compiling like a C source. (ussualy i know than it gives COMPILE ERROR when using inline functions but I thought it was something different because at the contest i submited a lot of things and probably I misunderstood some of the replies).
Thank you for your replies.
Rostislav
10941 - Words adjustment
Posted: Wed Oct 19, 2005 12:12 pm
by polone
How to determine the adjustment is possible or not?
I have no idea...

Posted: Wed Oct 19, 2005 12:50 pm
by polone
I just got AC that I assumed the upper bound is 3*k or less
but it's not fair... just a good luck
I remain wondering why it should pass
Posted: Thu Oct 20, 2005 7:17 pm
by Abednego
Nice example. I think is slightly wrong though. Here is code that generates a very similar example.
Code: Select all
#include <stdio.h>
char buf[4] = "aaa";
int main()
{
printf( "1\ntestaaa\ntest\n1000\nx\n" );
for( int i = 0; i < 999; i++ )
{
printf( "%s", buf );
for( int j = 0; j < 1000 - 6; j++ ) putchar( 'x' );
int carry = 1;
for( int j = 2; j >= 0; j-- )
{
buf[j] += carry;
if( buf[j] > 'z' ) { buf[j] = 'a'; carry = 1; }
else carry = 0;
}
if( i < 998 ) printf( "%s\n", buf );
else printf( "xxx\n" );
}
}
On this input, my accepted solution runs in 9.9 seconds on a 2.4GHz CPU and gives the answer
Posted: Thu Oct 20, 2005 8:30 pm
by Tamagodzi
My Solution takes about 40 sec with same answer

Posted: Mon Oct 24, 2005 9:03 am
by angga888
Hi, does anyone know the time limit of this problem during the contest?

Posted: Mon Oct 24, 2005 2:41 pm
by Adrian Kuegel
Abednego wrote:
On this input, my accepted solution runs in 9.9 seconds on a 2.4GHz CPU and gives the answer
My solution runs only 0.8 seconds on this test case, but I had to increase the number of nodes I allow in my prefix tree (which would give memory limit exceeded at the online judge).
I think that the judge test cases are very poor, and I fear that worst cases exist for every program, such that it will not terminate within 10 seconds.
Posted: Mon Oct 24, 2005 11:19 pm
by mf
Hi! Could someone post tricky test cases for this problem?
My program passes the test case mentioned above and also test cases from the original polish olympiad,
but it is getting WA here, and I really don't know why
And I'd like to ask, are there empty lines in the input? I use scanf(" %s",...) to read words, could this be a problem?
Posted: Tue Oct 25, 2005 3:02 am
by Cho
I think empty line is possible, although I don't know how to solve the problem yet.