102 - Ecological Bin Packing

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

Moderator: Board moderators

mindae
New poster
Posts: 8
Joined: Sun May 19, 2002 8:58 pm
Contact:

102 problem..

Post by mindae »

INPUT Data {1,2,3,4,5,6,7,8,9}; OUTPUT Data is GBC,GCB,BGC,BCG,CBG,CGBall correct .
Because 1,2,3.. is Arithmetic Sequence :oops:
Moreover Minimum size is constant also.

Tech me :(
+_+ o bba sal sal

mindae
New poster
Posts: 8
Joined: Sun May 19, 2002 8:58 pm
Contact:

T_T *3

Post by mindae »

Thx :0
but i got WA also.

INPUT
342343434 1000000000 234333333 21342134 12341234 12345345 3455555 5645656 5
234234 12341234 1234234 4563456 5674576 476476 45764576 45764576 23452345
21341234 12341234 12341234 234334 56456 4563456 34563456 78768 5685678
23423423 23 3 34234 234234 234234 234234 456456 78


OUTPUT

GBC 610464557
GCB 80923421
GCB 39737704
BCG 502806


i don't know that why i got WA.
+_+ o bba sal sal

ithamar
Learning poster
Posts: 56
Joined: Mon May 13, 2002 11:58 pm
Location: Venezuela

Post by ithamar »

You are right. GBC, GCB, BCG, ..., etc are correct but you have to read more carefuly the problem description because it says:

"If more than one order of brown, green, and clear bins yields the minimum number of movements then the alphabetically first string representing a minimal configuration should be printed. "



Hope it can help u.

bye

mindae
New poster
Posts: 8
Joined: Sun May 19, 2002 8:58 pm
Contact:

^-^

Post by mindae »

Thx
i can't read english,well.
thank you
;)
+_+ o bba sal sal

minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

"IN ALPHABETICAL ORDER"

Post by minskcity »

ALL you numbers are correct,
but for "1 2 3 4 5 6 7 8 9" Input
YOU should print "BCG 30"

mindae
New poster
Posts: 8
Joined: Sun May 19, 2002 8:58 pm
Contact:

Ok

Post by mindae »

BCG 30 ..
I repair my code . so minimum is select Foward alphabet.
But .. I recive WA from judge ,also
Probably i will crazy.. :(
+_+ o bba sal sal

ricky_bd
New poster
Posts: 3
Joined: Fri May 31, 2002 6:38 am

check the printf portion of your code

Post by ricky_bd »

konsept wrote:Can someone please tell what is wrong with this problem, because I can't figure out why the online judge fails to accept it.

#include <stdio.h>
#include <string.h>

int box[4][4];

int bestcost;
char bestbin[16];

int check( int a,int b,int c ){
int cost=0;

cost+=box[1][1]+box[1][2]+box[1][3]-box[1][a];
cost+=box[2][1]+box[2][2]+box[2][3]-box[2];
cost+=box[3][1]+box[3][2]+box[3][3]-box[3][c];

return cost;
}

void main( void ){

while ( scanf( "%d %d %d", &box[1][1],&box[1][2],&box[1][3] )>0 ){
scanf( "%d %d %d", &box[2][1],&box[2][2],&box[2][3] );
scanf( "%d %d %d", &box[3][1],&box[3][2],&box[3][3] );

bestcost=1000000;

if ( check(1,3,2)<bestcost ){
bestcost=check(1,3,2);
strcpy( bestbin, "BCG" );
}

if ( check(1,2,3)<bestcost ){
bestcost=check(1,2,3);
strcpy( bestbin, "BGC" );
}

if ( check(3,1,2)<bestcost ){
bestcost=check(3,1,2);
strcpy( bestbin, "CBG" );
}

if ( check(3,2,1)<bestcost ){
bestcost=check(3,2,1);
strcpy( bestbin, "CGB" );
}


if ( check(2,1,3)<bestcost ){
bestcost=check(2,1,3);
strcpy( bestbin, "GBC" );
}

if ( check(2,3,1)<bestcost ){
bestcost=check(2,3,1);
strcpy( bestbin, "GCB" );
}

printf( "%s %dn", bestbin, bestcost );
}

}


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

Post by Stefan Pochmann »

Ah, now I found it. You chose to fully quote the post you reply to (why?) and write your comment in the subject line.

Btw, the printf is probably correct. I guess you think the backslash is missing, but it was probably removed by this board and is included in the original code.

giovane
New poster
Posts: 2
Joined: Fri Jun 28, 2002 2:01 pm
Contact:

102 problem

Post by giovane »

I don't find the error with this algoritm...
Please, could anyone find it???
Thanks for help...

#include <stdio.h>
void main()
{
int i,min;
unsigned long int num[9],b[9],S[6];
while (scanf("%d %d %d %d %d %d %d %d %d",&num[0],&num[1],&num[2],&num[3],&num[4],&num[5],&num[6],&num[7],&num[8])==9)
{
b[0]=num[0]+num[3];
b[1]=num[0]+num[6];
b[2]=num[3]+num[6];
b[3]=num[1]+num[4];
b[4]=num[2]+num[7];
b[5]=num[4]+num[7];
b[6]=num[2]+num[5];
b[7]=num[2]+num[8];
b[8]=num[5]+num[8];
S[0]=b[2]+b[7]+b[3];
S[1]=b[2]+b[4]+b[6];
S[2]=b[8]+b[1]+b[3];
S[3]=b[8]+b[4]+b[0];
S[4]=b[5]+b[1]+b[6];
S[5]=b[5]+b[7]+b[0];
min=0;
for (i=0;i<6;i++)
if (S<S[min])
min=i;
switch (min)
{
case 0:
printf("BCG %d\n",S[0]);
break;
case 1:
printf("BGC %d\n",S[1]);
break;
case 2:
printf("CBG %d\n",S[2]);
break;
case 3:
printf("CGB %d\n",S[3]);
break;
case 4:
printf("GBC %d\n",S[4]);
break;
case 5:
printf("GCB %d\n",S[5]);
break;
}
}
}

:( [c][/c]
Last edited by giovane on Sat Jun 29, 2002 1:16 am, edited 1 time in total.

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

Post by 10153EN »

Despite your declaration of *unsigned long int*, your input using "%d" will read the value as *int*, So there will be value overflow when the input is 2^31 = 2147483648.

Picard
Learning poster
Posts: 96
Joined: Mon Jun 24, 2002 1:22 pm
Location: Hungary
Contact:

Post by Picard »

the real problem is b[4]=num[2]+num[7];

ps: remove your full ID code from the posted source

giovane
New poster
Posts: 2
Joined: Fri Jun 28, 2002 2:01 pm
Contact:

Thanks...

Post by giovane »

:D Thanks for your help...
I don't understand why I don'f find the error...

hello world
New poster
Posts: 4
Joined: Fri Aug 02, 2002 6:04 pm

help:102!

Post by hello world »

can someone tell me where i make a mistake?i always get WA.why?
thanks
[cpp]#include<iostream.h>


int main()
{
unsigned long bin[3][3];
/*bin[0][0] is the number of brown bottles of the first bin.
the other are similar.
0->brown,1->green,2->clear;and bin[1]->the second bin*/

int i,j,flag;
unsigned long c[6];
while(!cin.eof())
{

for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>bin[j];
c[0]=bin[0][1]+bin[0][2]+bin[1][0]+bin[1][1]+bin[2][0]+bin[2][2];//BCG
c[1]=bin[0][1]+bin[0][2]+bin[1][0]+bin[1][2]+bin[2][0]+bin[2][1];//BGC
c[2]=bin[0][0]+bin[0][1]+bin[1][1]+bin[1][2]+bin[2][0]+bin[2][2];//CBG
c[3]=bin[0][1]+bin[0][0]+bin[1][0]+bin[1][2]+bin[2][1]+bin[2][2];//CGB
c[4]=bin[0][0]+bin[0][2]+bin[1][1]+bin[1][2]+bin[2][0]+bin[2][1];//GBC
c[5]=bin[0][0]+bin[0][2]+bin[1][0]+bin[1][1]+bin[2][1]+bin[2][2];//GCB
unsigned long min=c[0];
flag=0;
for(i=1;i<6;i++)
{
if(min>c)
{
min=c;
flag=i;
}
}
switch (flag)
{
case 0:cout<<"BCG ";break;
case 1:cout<<"BGC ";break;
case 2:cout<<"CBG ";break;
case 3:cout<<"CGB ";break;
case 4:cout<<"GBC ";break;
case 5:cout<<"GCB ";break;
}
cout<<c[flag]<<endl;
}
return 0;
}




[/cpp]
Last edited by hello world on Fri Aug 02, 2002 6:43 pm, edited 2 times in total.

vivid
New poster
Posts: 6
Joined: Tue Jul 16, 2002 6:31 pm

Post by vivid »

May be not
bin[0][1]+bin[0][2]+bin[1][0]+bin[1][1]+bin[2][0]+bin[2][2]

but
bin[0][1]+bin[0][2]+bin[1][0]+bin[1][2]+bin[2][0]+bin[2][1] ?

hello world
New poster
Posts: 4
Joined: Fri Aug 02, 2002 6:04 pm

Post by hello world »

no.it should be the original code.

Post Reply

Return to “Volume 1 (100-199)”