Page 1 of 1
10651 - Pebble Solitaire
Posted: Wed Jan 18, 2006 9:06 pm
by Tomislav Novak
Hi. I'm trying to solve problem 10651. I have a variable mask which denotes the state (1 if there is a pebble in a cavity, 0 otherwise), and I'm using a memoized recursive function to calculate the minimum number of pebbles left. I also wrote a routine to print the optimal process of removing the pebbles, however I can't find a test case where it fails (WA on online judge). Perhaps I misunderstood the problem?
Here's my code:
Thanks in advance!
Posted: Thu Jan 19, 2006 10:57 am
by mamun
The input begins with a positive integer n on a line of its own. Thereafter n different games follow.
So don't wait fro EOF.
Posted: Thu Jan 19, 2006 3:13 pm
by Tomislav Novak
mamun wrote:So don't wait fro EOF.
It makes no difference. Still wrong answer.
Posted: Thu Jan 19, 2006 3:37 pm
by mamun
Here are some I/O for you
Input
Code: Select all
4
oo--oooo-ooo
oooo-oooo-oo
-oooo-oo-oo-
oooooooo-oo-
Output
Posted: Fri Jan 20, 2006 7:01 pm
by Tomislav Novak
mamun wrote:Here are some I/O for you
I've finally spotted the bug. It was the 'else if' part in my recursive function...

Thank you very much.
Re: 10651 - Pebble Solitaire
Posted: Fri Dec 12, 2008 3:15 am
by newkid
Hi,
I am trying to solve this problem. But all the time i get TLE. my code snippet is below..
Code: Select all
int state[15];
int getmin(int index) {
......
}
int main() {
int test;
char line[15];
char ch;
scanf("%d", &test);
while (test--) {
int index = 0;
for (int i = 0; i < 12;) {
ch = getchar();
if (ch == 'o' || ch == '-') {
index = index * 2 + (ch == 'o' ? 1 : 0);
state[i] = (ch == 'o' ? 1 : 0);
i++;
} else if (ch == '\n' || ch == (char)EOF)
break;
else
continue;
}
// i get TLE without even calling the getmin()..
//int res = getmin(index);
//printf("%d\n", res);
printf("%d\n", index%12);
}
return 0;
}
problem is i get TLE even without calling the getmin() function. I tried with gets() but the result is same..
help please..
Re: 10651 - Pebble Solitaire
Posted: Fri Dec 12, 2008 3:42 am
by newkid
got the problem.. its not with the input scanning.. I had one macro to hide freopen(..), my mistake was there..
anyway judge didn't give me Restricted Function.. that was odd!!