11376 - Tilt!

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

I get runtime error now, too.
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

Yes, I have sent them a new set of input/output, but I suppose they haven't had this task rejudged yet?

When I get home I will see if I have sent them a correct i/o set. By the way, can any of you send me your should-be-correct codes, so that I can use them to check if input file is indeed correct or not? Thanks.

[EDIT] I look at the copy of the files I sent (from my mailbox). They look correct to me. Of course "look" is a fairly weak word... :- )
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

I have received mf's code. I check it with the i/o set I sent to the admins and it gives correct answers! :-?
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG »

I think they finally got around to fixing it cause I got accepted now :). I however don't understand why my implementation of a priority queue for A* got WA. I assume it's because it returns a non lexigraphic solution. Shouldn't the priority queue be sorted by depth+heruistic, and if that is equal to another node shouldn't it be sorted by the order of when the node was pushed on the queue? I had to make it a regular queue to get it accepted, the only reason why it runs very fast is because the program knows if a square can't find all remaining goals so it doesn't add that square to be checked, other than that it is just BFS.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

I don't know why I am getting Run Time Error. I used IDA*(as pseudocode given by mf) to solve this problem. Can anyone help me, giving the idea why I am getting Run Time Error.
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG »

The few places I ran into RE with this problem was reading the goal cordinates in the wrong order. I also missed the fact that goal cordinates can have 2 digits. The last place I had trouble with RE was related to reading the cordinates wrong, and happened when the program would check a square that doesn't exist in the grid.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

I have taken inputs this way..
Is there any wrong..?

Code: Select all

#define mabs(x) ((x)<0?(-(x)):(x))
#define mmin(a,b) ((a)>(b)?(b):(a))
#define mmax(a,b) ((a)<(b)?(b):(a))
#define idig(x) ((x)>='0' && (x)<='9')


#define Fo(i,l,h) for((i)=l;(i)<=h;++(i))
#define fo(i,n) for((i)=0;(i)<n;++(i))

char g[20][20];
int grid[20][20];
int mark[20][20];
int blue, n, nblue;

int main (void){
	int i, j, k, m, a, b, x, y;
	char buff[100];
	//freopen("input.txt","r",stdin);
	gets(buff);
	n=atoi(buff);
	while(1){
		if(n==0)break;
		fo(i,n)gets(g[i]);
		fo(i,n)fo(j,n)if(idig(g[i][j]))grid[i][j]=g[i][j]-'0';
		else grid[i][j]=g[i][j]-'A'+10;
		fo(i,n)fo(j,n)mark[i][j]=-1;
		gets(buff);
		sscanf(buff,"%d%d",&x,&y);x--;y--;
		blue=0;
		k=0;
		while(gets(buff)){
			if(sscanf(buff,"%d%d",&a,&b)==2){
				blue++;
				a--;b--;
				mark[a][b]=k++;
				//printf("%d %d\n",a,b);
			}
			else break;
		}
		m=a;
		nblue=k;
		
////////////////////////// internal logic here........................
		
		n=m;//printf("%d\n",n);
	}

	return 0;
}
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG »

everything looks good, just make sure the program uses the cordinates given as row column and not column row.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

CMG wrote:everything looks good, just make sure the program uses the cordinates given as row column and not column row.
Sorry I can't get you, what do you mean by row column or column row? In my program by (x,y) I mean xth row and yth column.
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG »

(x,y) xth row yth column is correct.

If you have an error then it is probably related to something else in the logic part of the code.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Accepted at last
problem was in my logic
thanks CMG.
Post Reply

Return to “Volume 113 (11300-11399)”