Page 2 of 4

Posted: Thu Jun 26, 2003 6:00 pm
by bugzpodder
can you show me how to parse the input? i dont know how to do it...

Posted: Thu Jun 26, 2003 8:18 pm
by Dmytro Chernysh
If it was on CCC 2003, beleave me it's the same :-)

Did you take part it the second stage? If so, it would be VERY interesting to talk with you. Can you mail me?[/pascal]

P.E. For 124

Posted: Mon Aug 25, 2003 6:09 am
by xbeanx
I'm doing 124 (Following Orders) and I keep getting a P.E.

Here's the input and output for my program, can anyone see what's wrong?

Code: Select all

IN:
a b f g
a b b f
v w x y z
v y x v z v w v

OUT:
a b f g
a b g f
a g b f
g a b f

w x z v y
w z x v y
x w z v y
x z w v y
z w x v y
z x w v y

There are no extra spaces at the end of each line, and I have submitted it both WITH and WITHOUT the trailing newline. Both ways give me PE.

Here's some more IO

Code: Select all

IN:
a b f g
a b b f
v w x y z
v y x v z v w v
f g b a
a b b f
a b c d
a b b c
a e i o u
a e
a b c d
a b a c a d
a b c d e
a b b c c d d e
a b c d e f g h i
a b b c c d d e e f f g g h h i

OUT:
a b f g
a b g f
a g b f
g a b f

w x z v y
w z x v y
x w z v y
x z w v y
z w x v y
z x w v y

a b f g
a b g f
a g b f
g a b f

a b c d
a b d c
a d b c
d a b c

a e i o u
a e i u o
a e o i u
a e o u i
a e u i o
a e u o i
a i e o u
a i e u o
a i o e u
a i o u e
a i u e o
a i u o e
a o e i u
a o e u i
a o i e u
a o i u e
a o u e i
a o u i e
a u e i o
a u e o i
a u i e o
a u i o e
a u o e i
a u o i e
i a e o u
i a e u o
i a o e u
i a o u e
i a u e o
i a u o e
i o a e u
i o a u e
i o u a e
i u a e o
i u a o e
i u o a e
o a e i u
o a e u i
o a i e u
o a i u e
o a u e i
o a u i e
o i a e u
o i a u e
o i u a e
o u a e i
o u a i e
o u i a e
u a e i o
u a e o i
u a i e o
u a i o e
u a o e i
u a o i e
u i a e o
u i a o e
u i o a e
u o a e i
u o a i e
u o i a e

a b c d
a b d c
a c b d
a c d b
a d b c
a d c b

a b c d e

a b c d e f g h i

What's the trick to getting accepted?

Posted: Mon Aug 25, 2003 6:21 am
by Larry
Output for different constraint specifications is separated by a blank line
There's no blank line after the last line.. or at least mine didn't give one..

Posted: Mon Aug 25, 2003 11:50 am
by xbeanx
Thanks Larry. I tried submitting a version that doesn't print a newline at the end but also got PE.

However, I'll try once more. Maybe I overlooked something.

Posted: Mon Aug 25, 2003 4:50 pm
by UFP2161
Dumb question, but why are there spaces between the letters in your output?

Posted: Mon Aug 25, 2003 6:59 pm
by xbeanx
:oops: :roll: :oops:

OMG.. I can't believe I did not see that! How the heck did I miss that?

Man, I think I've been doing way to many of these problems lately.

Thanks UFP2161

#124 following orders..

Posted: Tue Feb 15, 2005 4:20 am
by lazenca
hi.. :o
I tried this prob these days...
But still got WA.
Is there some input cases I missed?
help me~

Posted: Tue Feb 15, 2005 10:37 am
by lazenca
oops... :roll:
I got AC now... >.<

CE in problem 124 [why error messages are so dumb?]

Posted: Sun May 01, 2005 9:27 am
by OZone
Hi! I've compiled following code in MSVC7.1 and even in Borland C. Everything is fine. So why do it gets compile errors in online judge?
I recieved by e-mail tough list of errors but they did not give me any clue to understang the problems. What is the character 0232, and why my declared variables suddenly became undeclared? The code is:

Code: Select all

#ifndef ONLINE_JUDGE
#include <iostream>
#include <io.h>
using namespace std;
#else
#include <iostream.h>
#include <stdio.h>
#endif

char* end, n;
char b[256];
char u[26];
char l[26];
char e[26];
char t[26];
char a[26][26];
char d[26][26];

void print(char i, char* p)
{
	*++p = l[u[i] = i];
	if (p < end){
		for (char *k, j = 0; j < n; ++j)
			if (u[j] == '-')//not used
				if (a[i][j] == '-' ||//belong to this chain
					d[i][j] != '-')  //and next in chain
				{
					for (k = p; k >= b; --k)
						if (a[j][e[*k-'a']] != '-') break;
					if (k < b) print(j, p);
				}
	}else printf(b);
	u[i] = '-';
}

void main()
{
#ifndef ONLINE_JUDGE
	close(0);
	open("input.txt", 0);
#endif
	while (1)
	{
		cin.getline(b, sizeof(b));
		if (cin.peek() < 0) break;
		char *p, c, c2, i, j; n = 0;
		memset(u, '-', sizeof(u));
		memset(l, '-', sizeof(l));
		memset(e, '-', sizeof(e));
		memset(a, '-', sizeof(a));
		memset(d, '-', sizeof(d));
		for (p = b; *p; p++)
			if ('a' <= *p && *p <= 'z')
				e[*p-'a'] = *p;
		for (c = 0; c < 26; c++)
			if (e[c] != '-')
				l[e[c] = n++] = c+'a',
				t[e[c]] = c + 'a';
		cin.getline(b, sizeof(b));
		for (p = b; *p; p++)
		{
			if (*p < 'a') continue;
			if (*p > 'z') continue;
			char* p2 = p;
			for (++p; *p; ++p)
			{
				if (*p < 'a') continue;
				if (*p > 'z') continue;
				break;
			}
			a[c2 = e[*p2-'a']][c = e[*p-'a']] = *p;
			d[c2][c] = *p;
			t[c] = '-';
			for (i = 0; i < n; i++)
			{
				if (a[i][c2] != '-')
					for (j = 0; j < n; ++j)
						if (a[c2][j] != '-')
                            a[i][j] = *p;
				if (a[i][c] != '-')
					for (j = 0; j < n; ++j)
						if (a[c][j] != '-')
							a[i][j] = l[j];
				if (a[i][c2] != '-'  && a[i][c] != '-')
					d[i][c] = '-';
			}
		}
		*((end = b + n - 1)+1) = '\n', *(end+2) = '\0';
		for (i = 0; i < n; ++i)
			if (t[i] != '-')//root of chain
				print(i, b-1);
		printf("\n");
	}
}
Sincerly yours, OZone! ;)

Re: CE in problem 124 [why error messages are so dumb?]

Posted: Sun May 01, 2005 11:49 pm
by misof
OZone wrote:Hi! I've compiled following code in MSVC7.1 and even in Borland C. Everything is fine. So why do it gets compile errors in online judge?
I recieved by e-mail tough list of errors but they did not give me any clue to understang the problems. What is the character 0232, and why my declared variables suddenly became undeclared? The code is:

Code: Select all

... deleted, see parent post... 
Sincerly yours, OZone! ;)
Well, my g++ says the following (unimportant messages omitted):

Code: Select all

a.cc:3:16: io.h: No such file or directory
a.cc: At global scope:
a.cc:37: error: `main' must return `int'
a.cc:37: error: return type for `main' changed to `int'
a.cc: In function `int main(...)':
a.cc:40: error: `open' undeclared (first use this function)
My observations:
- maybe it's a typo, but you have #ifndef where you want to have a #ifdef
- main must return an int (gosh.. the message DOES say this), add a "return 0;" at the end.
- there is no io.h under linux, but #include <iostream> is enough as you don't use the open() function in the version you want to submit

Posted: Mon May 02, 2005 7:53 am
by OZone
I've changed void main(void) to int main(void), I've deleted all debug code. It doesn't compiles also.
It is said about character 0232 - what is it? And the first line with errors in my code is: *++p = l[u = i];. Does their comiler parse such tokens?

Posted: Mon May 02, 2005 9:09 am
by OZone
It seems that problem is not in my source code. I tried to compile and run it in Kdevelop in Knoppix. Well, it's working. So I don't even know what to think about. Have anyone ideas?

Posted: Mon May 02, 2005 9:42 am
by chunyi81
Are you using submit-o-matic (the online submission system) or via e-mail?

I have no problems compiling your code after including the necessary headers and making the change recommended by misof.

Posted: Wed May 04, 2005 3:44 pm
by OZone
I have used e-mail and online posting system. And I recieved letter with following contents:
03526697_24.c: In function `void print(char, char *)':
03526697_24.c:22: parse error before character 0232
03526697_24.c:24: `j' undeclared (first use this function)
03526697_24.c:24: (Each undeclared identifier is reported only once
03526697_24.c:24: for each function it appears in.)
03526697_24.c:24: parse error before `)'
03526697_24.c:29: `k' undeclared (first use this function)
03526697_24.c:29: parse error before `)'
03526697_24.c: In function `int main(...)':
03526697_24.c:43: parse error before character 0232
03526697_24.c:48: parse error before character 0232
03526697_24.c:53: `p' undeclared (first use this function)
03526697_24.c:53: parse error before `)'
03526697_24.c:56: `c' undeclared (first use this function)
03526697_24.c:56: parse error before `)'
03526697_24.c:61: parse error before `)'
03526697_24.c:66: parse error before `)'
03526697_24.c: At top level:
03526697_24.c:75: parse error before `;'
03526697_24.c:75: syntax error before `++'
03526697_24.c:78: parse error before `;'
03526697_24.c:78: syntax error before `++'
03526697_24.c:82: parse error before `;'
03526697_24.c:82: syntax error before `++'
03526697_24.c:90: parse error before `;'
I do not understand what do they mean. It seems more worse than I even thought about.