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

Hisoka
Experienced poster
Posts: 120
Joined: Wed Mar 05, 2003 10:40 am
Location: Indonesia

Post by Hisoka » Sat Mar 15, 2003 5:22 pm

for another problem if the end of data or process is EOF, you can use that instead of use scan_r.

Good Luck........ :wink:

29145
New poster
Posts: 3
Joined: Sun Mar 09, 2003 10:29 am
Location: india

can any one tell me whats wrong

Post by 29145 » Mon Mar 17, 2003 2:22 pm

[c]#include<stdio.h>

int main()
{
unsigned long int b[3][3],min,j;
int no ;
while(scanf("%ld %ld %ld %ld %ld %ld %ld %ld %ld",&b[0][0],&b[0][1],&b[0][2],&b[1][0],&b[1][1],&b[1][2],&b[2][0],&b[2][1],&b[2][2]) == 9)

{
j = min = no = 0;
//for bcg
j = b[1][0]+b[2][0] + b[0][2]+b[2][2] + b[0][1]+b[1][1];
min = j;
no = 1;

// for bgc
j = b[1][0]+b[2][0] + b[0][1]+b[2][1] + b[0][2]+b[1][2];
if (j<min)
{
min = j;
no = 2;
}

// for cbg
j = b[1][2]+b[2][2] + b[0][0]+b[2][0] + b[0][1]+b[1][1];
if (j < min )
{
min = j;
no = 3;
}

//for cgb

j = b[1][2]+b[2][2] + b[0][1]+b[2][1] + b[0][0]+b[1][0];
if (j < min )
{
min = j;
no = 4;
}

//for gbc
j = b[1][1]+b[2][1] + b[0][0]+b[2][0] + b[0][2]+b[1][2];
if (j < min )
{
min = j;
no = 5;
}

// for gcb
j = b[1][1]+b[2][1] + b[0][2]+b[2][2] + b[0][0]+b[1][0];
if (j < min )
{
min = j;
no = 6;
}

switch(no)
{
case 1:
printf("BCG %ld",min);
break;
case 2:
printf("BGC %ld",min);
break;

case 3:
printf("CBG %ld",min);
break;

case 4:
printf("CGB %ld",min);
break;

case 5:
printf("GBC %ld",min);
break;

case 6:
printf("GCB %ld",min);
break;
}


}
return 0;
}[/c]

bery olivier
Learning poster
Posts: 90
Joined: Sat Feb 15, 2003 1:39 am
Location: Paris, France
Contact:

Post by bery olivier » Mon Mar 17, 2003 4:20 pm

I cannot see it on the board, but I suppose you put '\n' in your printfs. Your code seems ok, but for display or scan an unsigned long, you should use "%lu".
Not AC yet Image AC at last Image

bery olivier
Learning poster
Posts: 90
Joined: Sat Feb 15, 2003 1:39 am
Location: Paris, France
Contact:

Post by bery olivier » Tue Mar 18, 2003 11:33 am

:-? I cannot find anything wrong in your code. I sent it and got AC. Your code is ok.
Not AC yet Image AC at last Image

User avatar
Pier
New poster
Posts: 38
Joined: Thu Mar 27, 2003 9:12 pm
Location: Aguascalientes, Mexico
Contact:

Help with problem 102!

Post by Pier » Mon Mar 31, 2003 5:08 am

Hi! Here's my code. Any help aprecciated.

[pascal]Const
l: array [0..2] of char = ('C','B','G');

Var
i,s,tot: Longint;
r: string[3];
n: array [1..9] of longint;

Procedure intenta (a,b,c: longint);
begin
if (n[a]+n+n[c]) > s then
begin
s:= n[a]+n+n[c];
r:= l[a mod 3] + l + l[c mod 3];
end;
end;

Begin
While (not eof(input)) do
begin
tot:= 0; s:= 0;
for i:= 1 to 9 do
begin
read(input,n);
Inc(tot, n);
end;
intenta(1,6,8 ); intenta(1,5,9); intenta(3,4,8 );
intenta(3,5,7); intenta(2,4,9); intenta(2,6,7);
writeln(output,r,' ',tot -s);
end;
End.[/pascal]
There are 10 kind of people on this world: those who understand binary and those who don't!

Incognegro
New poster
Posts: 4
Joined: Tue Mar 25, 2003 9:52 pm

Post by Incognegro » Mon Mar 31, 2003 5:53 am

You are accumulating larger values of s in intenta as you try out
the different possibilities. I think your mistake is in assuming that
the smallest value for bottle movements is total - the largest value.

Just accumulate on the smallest value instead and forget the
subtraction from total idea.

ben
New poster
Posts: 1
Joined: Mon Apr 14, 2003 12:58 am

Wierd run time error

Post by ben » Mon Apr 14, 2003 1:02 am

****************************************
Your program has died with signal 25 (SIGXFSZ). Meaning:

File size limit exceeded
****************************************
I got above error when I sent problem 102.
I do not know how to ranslate the judge's response
Can some body PLZ help me?
Thanx very much

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Mon Apr 14, 2003 8:48 am

maybe you try to send file with your program, which exceeds limit ?
(40 kB If I remember ...)
I don't know, which other posibilities could be ...

DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:

It's one of possible problem...

Post by soyoja » Tue Apr 15, 2003 10:25 am

Because of your mail server system's operations, your mail could be attach dummy code.... I experienced similar case last year.
If your source code seems no problems, then trying online submit or
sending by other mail server.

uvarod
New poster
Posts: 2
Joined: Fri Apr 18, 2003 10:50 pm
Location: Brazil

No idea to fix 102!!Somebody help, pls!!!

Post by uvarod » Sat Apr 19, 2003 1:38 am

[pascal]
I can
Last edited by uvarod on Sun Apr 20, 2003 4:08 pm, edited 6 times in total.

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Post by Eric » Sat Apr 19, 2003 7:14 am

Oh, I can hardly understand your code.
First, why you output something like 'IVM' other than that given in the question 'BCG'.
Second, how come you compare teo integers?
if b[4]=b[5] or b[6] then
for example, b[5]=30 and b[6]=50
then your code is doing :

Code: Select all

b[5]         = 011110
b[6]         = 110010
----------------------------
b[5] or b[6] = 111110 = 63 ?!
Can you see that?

Farid Ahmadov
Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan

Post by Farid Ahmadov » Sat Apr 19, 2003 3:53 pm

I have got AC.
This is a very easy problem.
Just check all variations of BCG in a cycle to get the maximum sum of the glasses in bins. And don't forget to choose first in alphabetical order.
Good luck. I hope that it can help you.
_____________
NO sigNature

Farid Ahmadov
Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan

Post by Farid Ahmadov » Sat Apr 19, 2003 9:18 pm

The fragment of code:

A is first bin
B is second bin
C is third bin
this is a cycle.
the other part of program you must do yourself :wink:

for i:=1 to 3 do
for j:=1 to 3 do
if j<>i then
for k:=1 to 3 do
if (k<>j)and(k<>i) then
if A+B[j]+C[k]>max then

with this I have got AC.

Your program is tooooo long.
_____________
NO sigNature

uvarod
New poster
Posts: 2
Joined: Fri Apr 18, 2003 10:50 pm
Location: Brazil

Need help 102!!!Somebody say something!!!

Post by uvarod » Mon Apr 21, 2003 6:06 pm

[quote]Somebody, please take a look at my code and try give some idea about how to fix it. The trouble is, for example, inputs like 7 8 24 28 42 0 50 19 36 work very well, but some like 50 10 5 20 10 5 10 20 10 don

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Post by Eric » Mon Apr 21, 2003 6:22 pm

if b[1]<b[2] and b[3] and b[4] and b[5] and b[6] then
I think what you want to write should be
[pascal]if (b[1]<b[2]) and (b[1]<b[3]) and (b[1]<b[4]) and
(b[1]<b[5]) and (b[1]<b[6]) then[/pascal]
And you need not to have nested if, simply six if statements are enough.
You just need to find the strictly smallest one. Do you see it?

Post Reply

Return to “Volume 1 (100-199)”