Page 9 of 33

Posted: Sat Mar 15, 2003 5:22 pm
by Hisoka
for another problem if the end of data or process is EOF, you can use that instead of use scan_r.

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

can any one tell me whats wrong

Posted: Mon Mar 17, 2003 2:22 pm
by 29145
[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]

Posted: Mon Mar 17, 2003 4:20 pm
by bery olivier
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".

Posted: Tue Mar 18, 2003 11:33 am
by bery olivier
:-? I cannot find anything wrong in your code. I sent it and got AC. Your code is ok.

Help with problem 102!

Posted: Mon Mar 31, 2003 5:08 am
by Pier
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]

Posted: Mon Mar 31, 2003 5:53 am
by Incognegro
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.

Wierd run time error

Posted: Mon Apr 14, 2003 1:02 am
by ben
****************************************
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

Posted: Mon Apr 14, 2003 8:48 am
by Dominik Michniewski
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

It's one of possible problem...

Posted: Tue Apr 15, 2003 10:25 am
by soyoja
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.

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

Posted: Sat Apr 19, 2003 1:38 am
by uvarod
[pascal]
I can

Posted: Sat Apr 19, 2003 7:14 am
by Eric
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?

Posted: Sat Apr 19, 2003 3:53 pm
by Farid Ahmadov
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.

Posted: Sat Apr 19, 2003 9:18 pm
by Farid Ahmadov
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.

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

Posted: Mon Apr 21, 2003 6:06 pm
by uvarod
[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

Posted: Mon Apr 21, 2003 6:22 pm
by Eric
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?