Page 6 of 33

Posted: Sun Oct 20, 2002 2:44 am
by supermin
Ya....I got accepted message!!!
Thank you very much.!!
I think that my "supposed" test input is too small...right..? ^^"

Posted: Wed Oct 23, 2002 12:51 pm
by displesmer
If two or more states result in same minimum movements then alphabetically first string representing a minimal configuration should be printed.
Best Regards
:D

...

Posted: Sun Oct 27, 2002 5:32 am
by Archer
u should reset switcher to zero at the beginning of the while loop, else it will print wrong BGC combinations.

Alphabetical Order

Posted: Sun Oct 27, 2002 9:42 am
by Eric
displesmer wrote:If two or more states result in same minimum movements then alphabetically first string representing a minimal configuration should be printed.
Best Regards
:D
The above algorithm should have already sort the alphabetical order. The problem should be the value of max and initialization.

prob 102

Posted: Mon Nov 11, 2002 3:59 pm
by Axl
Wrong Answer: 102
Your program has not solved the problem. It ran during 0.152 seconds.


#include <stdio.h>
unsigned int caixas[9];
int i,menor;
float menora[6];

main()
{
while (scanf("%d %d %d %d %d %d %d %d %d",
&caixas[0],&caixas[1],&caixas[2],
&caixas[3],&caixas[4],&caixas[5],
&caixas[6],&caixas[7],&caixas[8])==9)
{
/*"BCG";*/
menora[0]=caixas[1]+caixas[2]+caixas[3]+caixas[4]+caixas[6]+caixas[8];
/*"BGC";*/
menora[5]=caixas[1]+caixas[2]+caixas[3]+caixas[5]+caixas[6]+caixas[7];
/*"CBG";*/
menora[1]=caixas[0]+caixas[1]+caixas[4]+caixas[5]+caixas[6]+caixas[8];
/*"CGB";*/
menora[4]=caixas[0]+caixas[1]+caixas[3]+caixas[5]+caixas[7]+caixas[8];
/*"GBC";*/
menora[3]=caixas[0]+caixas[2]+caixas[4]+caixas[5]+caixas[6]+caixas[7];
/*"GCB";*/
menora[2]=caixas[0]+caixas[2]+caixas[3]+caixas[4]+caixas[7]+caixas[8];
menor=0;

for (i=1;i<6;i++)
if (menora[menor]>menora[i]) menor=i;
if (menor==0)
printf("BCG %d\n", menora[menor]);
else if (menor==1)
printf("CBG %d\n", menora[menor]);
else if (menor==2)
printf("GCB %d\n", menora[menor]);
else if (menor==3)
printf("GBC %d\n", menora[menor]);
else if (menor==4)
printf("CGB %d\n", menora[menor]);
else if (menor==5)
printf("BGC %d\n,", menora[menor]);
}
}

Re: prob 102

Posted: Mon Nov 11, 2002 8:08 pm
by ashfaq_csdu
Axl wrote:Wrong Answer: 102
Your program has not solved the problem. It ran during 0.152 seconds.


:o float menora[6];

if (menor==0)
printf("BCG %d :o \n", menora[menor]);
The problem is here.
floating numbers but you are using "%d" :o
use long int instead

ashfaq

the updated version with the same prob...

Posted: Tue Nov 12, 2002 12:13 am
by Axl
#include <stdio.h>
long int caixas[9];
int i,menor;
long int menora[6];

main()
{
while (scanf("%d %d %d %d %d %d %d %d %d",
&caixas[0],&caixas[1],&caixas[2],
&caixas[3],&caixas[4],&caixas[5],
&caixas[6],&caixas[7],&caixas[8])==9)
{
/*"BCG";*/
menora[0]=caixas[1]+caixas[2]+caixas[3]+caixas[4]+caixas[6]+caixas[8];
/*"BGC";*/
menora[5]=caixas[1]+caixas[2]+caixas[3]+caixas[5]+caixas[6]+caixas[7];
/*"CBG";*/
menora[1]=caixas[0]+caixas[1]+caixas[4]+caixas[5]+caixas[6]+caixas[8];
/*"CGB";*/
menora[4]=caixas[0]+caixas[1]+caixas[3]+caixas[5]+caixas[7]+caixas[8];
/*"GBC";*/
menora[3]=caixas[0]+caixas[2]+caixas[4]+caixas[5]+caixas[6]+caixas[7];
/*"GCB";*/
menora[2]=caixas[0]+caixas[2]+caixas[3]+caixas[4]+caixas[7]+caixas[8];

menor=0;

for (i=1;i<6;i++)
if (menora[menor]>menora[i]) menor=i;
if (menor==0)
printf("BCG %d\n", menora[menor]);
else if (menor==1)
printf("CBG %d\n", menora[menor]);
else if (menor==2)
printf("GCB %d\n", menora[menor]);
else if (menor==3)
printf("GBC %d\n", menora[menor]);
else if (menor==4)
printf("CGB %d\n", menora[menor]);
else if (menor==5)
printf("BGC %d\n,", menora[menor]);
}
}

Re: the updated version with the same prob...

Posted: Tue Nov 12, 2002 8:36 am
by ashfaq_csdu
Axl wrote:
/*"GBC";*/ :-?
menora[3]=caixas[0]+caixas[2]+caixas[4]+caixas[5]+caixas[6]+caixas[7];
/*"GCB";*/ :-?
menora[2]=caixas[0]+caixas[2]+caixas[3]+caixas[4]+caixas[7]+caixas[8];
I think the problem is there.
surely GBC comes before GCB. But you wrote menora[3] = GBC
and menora[2] = GCB. As a result GCB comes first. :wink:


ashfaq

Problem 102

Posted: Thu Nov 14, 2002 9:58 pm
by reyalp
Wrong answer
please advise


#include <iostream>
using namespace std;
unsigned long int input[9];
unsigned long int mini(unsigned long int num[])
{
int i;
unsigned long int min;
min=num[0];
for (i=1;i<7;i++){
if(num<min) min=num;
}
return min;
}
unsigned long int move(int i)
{
switch(i){
case 1: return(input[1]+input[2]); //b1
case 2: return(input[4]+input[5]); //b2
case 3: return(input[7]+input[8]); //b3
case 4: return(input[0]+input[1]); //c1
case 5: return(input[3]+input[4]); //c2
case 6: return(input[6]+input[7]); //c3
case 7: return(input[0]+input[2]); //g1
case 8: return(input[3]+input[5]); //g2
case 9: return(input[6]+input[8]); //g3
}
}
void show(int i)
{

switch(i){
case 1:cout<<"BCG ";break;
case 2:cout<<"BGC ";break;
case 3:cout<<"CBG ";break;
case 4:cout<<"CGB ";break;
case 5:cout<<"GBC ";break;
case 6:cout<<"GCB ";break;
}
}
void main()
{
int i;
unsigned long int min;
unsigned long int num[6];
while(cin>>input[0]>>input[1]>>input[2]>>input[3]>>input[4]>>input[5]>>input[6]>>input[7]>>input[8])
{
num[0]=move(1)+move(5)+move(9);
num[1]=move(1)+move(8 )+move(6);
num[2]=move(4)+move(2)+move(9);
num[3]=move(4)+move(8 )+move(3);
num[4]=move(7)+move(2)+move(6);
num[5]=move(7)+move(5)+move(3);
min=mini(num);
for (i=0;i<=5;i++){
if(num==min){
show(i+1);
cout<<min<<endl;
break;
}
}
}
}

#102

Posted: Sun Nov 17, 2002 5:39 am
by Yes
I got WA.
HELP!!

[c]
#include <stdio.h>

int main()
{
int i, j, glass[3][3], sum[7] = {0}, min;

while( scanf( "%d%d%d%d%d%d%d%d%d", &glass[0][0], &glass[0][1],
&glass[0][2], &glass[1][0], &glass[1][1], &glass[1][2],
&glass[2][0], &glass[2][1], &glass[2][2] ) != EOF )
{
sum[0] = 0;

for( i = 0; i < 3; i++ )

for( j = 0; j < 3; j++ )

sum[0] += glass[j];

sum[1] = sum[0] - glass[0][0] - glass[1][1] - glass[2][2];

sum[2] = sum[0] - glass[0][0] - glass[2][1] - glass[1][2];

sum[3] = sum[0] - glass[1][0] - glass[0][1] - glass[2][2];

sum[4] = sum[0] - glass[1][0] - glass[2][1] - glass[0][2];

sum[5] = sum[0] - glass[2][0] - glass[0][1] - glass[1][2];

sum[6] = sum[0] - glass[2][0] - glass[1][1] - glass[0][2];

min = sum[2];

j = 2;

if( sum[1] < min )
{
min = sum[1];

j = 1;
}
if( sum[5] < min )
{
min = sum[5];

j = 5;
}
if( sum[6] < min )
{
min = sum[6];

j = 6;
}
if( sum[3] < min )
{
min = sum[3];

j = 3;
}
if( sum[4] < min )
{
min = sum[4];

j = 4;
}
switch( j )
{
case 1:

printf( "BGC" );

break;

case 2:

printf( "BCG" );

break;

case 3:

printf( "GBC" );

break;

case 4:

printf( "CBG" );

break;

case 5:

printf( "GCB" );

break;

case 6:

printf( "CGB" );

break;

default:

break;
}
printf( " %d\n", min );
}
return 0;
}
[/c]

something about 102...

Posted: Sun Nov 17, 2002 3:02 pm
by Haomiao
method...
who can tell me...
a bit of thanks...

Posted: Thu Nov 21, 2002 2:36 pm
by ezra
you got integer overflow because the total number of botlle reached 2^31.
Read the problem once again.

Posted: Thu Nov 21, 2002 6:19 pm
by Yes
I still got WA even if I use "long long" :cry:

Posted: Sun Nov 24, 2002 10:43 pm
by Larry
Try all combinations, there's only a few of them.

Posted: Tue Nov 26, 2002 3:26 pm
by Balon
dear comrade Hao,
You can use 3 nesting for() loop, soooooooooo easy, isn't it :lol: :lol: :lol: :lol:
If you still don't know how to do it , you can ask Balon Fan directly, HenHenHen :lol: :lol: :lol: :lol: