10230 - Savage Garden

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

Moderator: Board moderators

Post Reply
User avatar
DemonCris
New poster
Posts: 25
Joined: Sun Feb 24, 2002 2:00 am
Location: Taiwan

10230 - Savage Garden

Post by DemonCris »

Is there any trap in this problem ?

Or is there any strange input ?

I can run my sample input correctly up to
2^10 dimension.

Thank you ^^
Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post by Stefan Pochmann »

I don't think there's a trap. And the input is as easy as it can get. Are you sure your program is correct? Can we see your output for, lets say, "5 20 14"?

Or maybe you should check decreasing sizes in the input. This is always a good technique: reverse the order of the test cases (of course here we only have one, so one has to invent some first).
User avatar
DemonCris
New poster
Posts: 25
Joined: Sun Feb 24, 2002 2:00 am
Location: Taiwan

Post by DemonCris »

As you say "Or maybe you should check decreasing sizes in the input. This is always a good technique: reverse the order of the test cases (of course here we only have one, so one has to invent some first)."


I can't figure out it ...
It sounds like a good method to test your program, doesn't it?
Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post by Stefan Pochmann »

I'm not sure I understand what you mean with your last posting. Do you mean you tried it and your program still worked fine?

Please post the requested example output, maybe that will tell us more...
bolster
New poster
Posts: 16
Joined: Tue Oct 30, 2001 2:00 am

Post by bolster »

I'm getting WA for it too... it might be because of the way I do the output...

they say you can use a-z, but I only actually use a-f (cause you don't really need the others... the neighbours are still ok)

Code: Select all

bbccddbbddbbddbbddbbddbbddbbddbb
baacdaabdaabdaabdaabdaabdaabdaab
cabbeeaceacceeaceacceeaceacceeac
ccbaaecceecaaecceecaaecceecaaecc
ddeabbddffbbafbbffbaffbbffbbafbb
daeebaadfaabffabfabbfaabfaabffab
baacdabbccadcaadcaadcaddccadcaad
bbccddbaacddccddccddccdaacddccdd
ddeeffcabbeeffbbeebbeebbaebbeebb
daaefaccbaaefaabeaabeaabeeabeaab
baccbaadeabbccadcaddccadcaadccad
bbcabbddeebaacddccdaacddccddacdd
ddeaafccffcabbeeffbbaebbeebaaebb
daeeffacfaccbaaefab*eeabeabbeeab
baacbaadbaadeabbcaadbaacdaacdaac
bbccbbddbbddeebaccddbbccddccddcc
ddeeffcceeccffcaabeeffeeffbbeebb
daaefaaceaacfaccbbaefaaefaabeaab
baccbbadbaddbaadeaabccabcaddccad
bbcaabddbbdabbddeebbacbbccdaacdd
ddeaffcceecaaeccffcaaeddeebbaebb
daeefaaceacceeacfacceeadeaabeeab
baacbaddbaadbaadbaadbaacbbacdaac
bbccbbdabbddbbddbbddbbccabccddcc
ddeeffcaaecceecceecceedaaeffbbee
daaefacceeaceaaceaaceaddeeafbaae
baccbaadbaadbbadbaddbaacbaacddab
bbcabbddbbddabddbbdabbccbbccadbb
ddeaafcceecaaecceecaaeddeedaaecc
daeeffaceacceeaceacceeadeaddeeac
baacbaadbaadbaadbaadbaacbaacbaad
bbccbbddbbddbbddbbddbbccbbccbbdd
Am I misinterpreting it? And do they want an extra blank line between test cases? thanks...

bolster

<font size=-1>[ This Message was edited by: bolster on 2002-03-23 17:26 ]</font>

<font size=-1>[ This Message was edited by: bolster on 2002-03-23 17:27 ]</font>
Stefan Pochmann
A great helper
Posts: 284
Joined: Thu Feb 28, 2002 2:00 am
Location: Germany
Contact:

Post by Stefan Pochmann »

Looks good. Only L's, didn't see any adjacent L's of same color, '*' is at the right spot.

Yes, the problem states that there has to be a blank line after each testcase.

My accepted program has the blank lines and doesn't get higher than 'i'.
bolster
New poster
Posts: 16
Joined: Tue Oct 30, 2001 2:00 am

Post by bolster »

Woohoo I got AC! =)

it really WAS the new line thing... missed it i guess... i'm surprised it didn't give me format error though. thanks
xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

Am I misinterpreting the question?

Post by xenon »

I read the problem description ten times, but I think the following solution to the input "5 20 14" is in accordance with it. Getting WA's make me feel there should only be tiny Ls. Am I right? Or is my code wrong :(

Code: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empty lines after each test case).
10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

Post by 10153EN »

Yes, there should be only *tiny L-shapes* as you said.

There's sth you have misunderstood with the problem :wink:
Amir Aavani
New poster
Posts: 30
Joined: Wed Oct 23, 2002 6:53 am

what can i do to avoid TL?

Post by Amir Aavani »

i try to solve it, i use a recursive approach,
Solve (Top, Left, Height, Width: Integer; Pt: TPoint; CharName: char)

where Pt is the place of the space.

is there any special point?
please help :wink:
bunnyxl
New poster
Posts: 4
Joined: Fri Jun 29, 2012 6:32 am

10230 - Savage Garden

Post by bunnyxl »

Hi, I am trying to solve the problem 10230 but always got WA. I've tried a lot of test cases, but still can't figure out what's wrong. Can anyone help me with that? Is there some special cases ? Thank you :)

Code: Select all

#include<iostream>
#include<stdlib.h>
using namespace std;

int a,b,n,s;
char map[1024][1024];
int al[26];

void mark(int x, int y){
	al[map[x-1][y-1]-'a']=1;
	al[map[x-1][y]-'a']=1;
	al[map[x-1][y+1]-'a']=1;
	al[map[x][y-1]-'a']=1;
	al[map[x][y+1]-'a']=1;
	al[map[x+1][y-1]-'a']=1;
	al[map[x+1][y]-'a']=1;
	al[map[x+1][y+1]-'a']=1;
}

char getal(int x1,int y1, int x2, int y2, int x3, int y3){
	int i,j;
	for(i=0; i<26; i++)
		al[i]=0;
	mark(x1,y1);
	mark(x2,y2);
	mark(x3,y3);
	for(i=0; i<26; i++)
		if(!al[i])
			return i+'a';
}

void div(int x0, int y0,int s, int a, int b){
	char c;
	int k;
	int halfx = s/2+x0;
	int halfy = s/2+y0;
	int x1,x2,x3,x4;
	int y1,y2,y3,y4;
	x1 =x3= halfx-1;
	x2 =x4= halfx;
	y1 =y2= halfy-1;
	y3 =y4= halfy;
	int x01,x02,x03,x04;
	int y01,y02,y03,y04;
	x01 = x03=x0;
	x02 = x04=halfx;
	y01 = y02=y0;
	y03 = y04=halfy;
	int a1,a2,a3,a4;
	int b1,b2,b3,b4;
	a1=a3=x1;
	a2=a4=x2;
	b1=b2=y1;
	b3=b4=y3;
	if(a <halfx){
		k = 3;
		if(b<halfy)
			k = 1;
	}
	if(a >=halfx){
		k= 4;
		if(b < halfy)
			k = 2;
	}
	switch(k){
		case 1:c=getal(x2,y2,x3,y3,x4,y4);map[x2][y2]=map[x3][y3]=map[x4][y4]=c;a1=a, b1=b;break;
		case 2:c=getal(x1,y1,x3,y3,x4,y4);map[x1][y1]=map[x3][y3]=map[x4][y4]=c;a2=a, b2=b;break;
		case 3:c=getal(x1,y1,x2,y2,x4,y4);map[x1][y1]=map[x4][y4]=map[x2][y2]=c;a3=a, b3=b;break;
		case 4:c=getal(x1,y1,x3,y3,x2,y2);map[x1][y1]=map[x2][y2]=map[x3][y3]=c;a4=a, b4=b;break;
	}
	if(s==2)
		return;
	div(x01,y01,s/2,a1,b1);
	div(x02,y02,s/2,a2,b2);
	div(x03,y03,s/2,a3,b3);
	div(x04,y04,s/2,a4,b4);
}

int main(){
	int i,j,k;
	int wc=0;
	while(cin >> n >> a >> b){
		s=1;
		while(n--)
			s*=2;	
		for(i=0;i<s;i++)
			for(j=0;j<s;j++)
				map[i][j]=0;
		div(0,0,s, a-1, b-1);
		map[a-1][b-1]='*';
		for(i=0; i<s; i++){
			for(j=0; j<s; j++)
				cout << map[j][i];
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10230 - Savage Garden

Post by brianfry713 »

Try this input on your code: 10 923 871
At the end a number of lines including #233 you're printing an illegal character.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 102 (10200-10299)”