414 - Machined Surfaces

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

Moderator: Board moderators

razib
New poster
Posts: 1
Joined: Fri Apr 12, 2002 4:05 am

414

Post by razib »

I get the correct result for the 1st case.
then I get wrong answer.
Here is my code.........

#include <stdio.h>

void main()
{
int x,y,a,b,c,d,n,h,t,xn[13];
char im[13][26];
do
{
scanf("%d",&n);

for(a=0;a<n;a++)
for(b=0;b<25;b++)
scanf("%c",&im[a]);
for(a=0;a<n;a++)
{
c=0;
for(b=0;b<25;b++)
{
if(im[a]!='X')
continue;
c++;
}
xn[a]=c;
}
h=0;
for(a=0;a<n;a++)
if(xn[a]>h)
h=xn[a];

t=0;
for(a=0;a<n;a++)
t+=h-xn[a];
printf("%d\n",t);
}while(n!=0);

}
[/code]
Razib
E.L
New poster
Posts: 2
Joined: Sun Dec 08, 2002 11:09 pm

Please, give me more sample input&output 414

Post by E.L »

[c]
can you give more sample input and output, for 414 problem?
and could you tell me the input 'x' or 'X'.

thanks for your help..........[/c]
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

Post by angga888 »

1
XBBBBBBBBBBBBBBBBBBBBBBBX
3
XBBBBBBBBBBBBBBBBBBBBBBBX
XXXXXXXXXXXXBBXXXXXXXXXXX
XBBBBBBBBBBBBBBBBBBBBBBBX
1
XXXXXXXXXXXXXXXXXXXXXXXXX
3
XXXBBBBBBBBBBBBBBBBBBBBBX
XXXXXXXBBBBBBBBBBBBBBXXXX
XXXXXXXXBBBBBBBBBBBBBBBBX

{"B" shows the space.}

Output:
0
42
0
9

The input is 'X' (UPPERCASE LETTER)

Good luck! :lol:

Regards,
Angga888
E.L
New poster
Posts: 2
Joined: Sun Dec 08, 2002 11:09 pm

Post by E.L »

thanx for your help, I got AC now....
pc5971
New poster
Posts: 34
Joined: Mon Aug 05, 2002 11:24 am
Contact:

Post by pc5971 »

Can you tell me what's wrong with my code. I verified with all this input and it works... The idea is that I calculate the sum of all spaces (sum) and the minimum number of the spaces in a line (min). The oputput is then sum-n*min... Is it ok???


[pascal]
program p414;
var s:string;
sum:longint;
n,min,i,k,j:integer;

begin
while not eof(input) do
begin
readln(n);
min:=MaxInt; sum:=0;
for i:=1 to n do
begin
readln(s);
while s[1]=' ' do delete(s,1,1);
j:=length(s);
while s[j]=' ' do
begin
delete(s,j,1);
j:=j-1;
end;
k:=0;
j:=pos(' ',s);
while j>0 do
begin
delete(s,j,1);
k:=k+1;
j:=pos(' ',s);
end;
sum:=sum+k;
if min>k then
min:=k;
end;
writeln(sum-min*n);
end;
end.
[/pascal]

Thanx
User avatar
Sarmento
New poster
Posts: 15
Joined: Tue Apr 22, 2003 9:50 pm
Location: Lisboa, Portugal

414-Is anything wrong with my code? The answers are correct

Post by Sarmento »

All the answers seem to be correct. I don't know why I get WA.....
Can anyone help me out?

Thanks in advance,

joao sarmento

[java]

import java.io.*;
class Main{

public static void main (String args[]){
Main myWork = new Main(); // create a dinamic instance
myWork.Begin(); // the true entry point
}

void Begin(){
int [] blanks = new int[13];
int x = -1;
int result = 0;
int line = -1;
int lines = 0;
while(x != 0){
try{
x = System.in.read();
}
catch (IOException e){
System.out.println(e.getMessage());
System.out.println("Fatal error. Ending Program.");
System.exit(0);
}
if (x == '0'){
x = 0;
}
else if (x > '0' && x <= '9'){
lines = x - '0';
line = -1;
}
else if (x == 'X' || x == '\r'){
}
else if (x == ' ')
blanks[line]++;
else if (x == '\n'){
line++;
if (line >= lines){
int min = 25;
for(int i = 0; i < lines; i++)
if (blanks < min)
min = blanks;
for(int i = 0; i < lines; i++)
result+= (blanks - min);
System.out.println(result);
blanks = new int [13];
result = 0;
lines = 0;
line = -1;
}
}
}
}
}[/java]
-----------------
Jo
Admus
New poster
Posts: 8
Joined: Mon Sep 29, 2003 3:13 pm

414-Wa? Why? Please help!

Post by Admus »

I've got a problem with my program.
Please help me
These is source

Code: Select all

var
  c,il,suma,a,b,min:longint;
  wyn:array[1..13]of longint;
  s:string;
  czy:boolean;
begin
  {assign(input,'414.in');
  reset(input);}
  readln(il);
  while il<>0 do
    begin
      min:=maxlongint;
      czy:=false;
      for a:=1 to il do
        begin
          readln(s);
          c:=0;
          b:=1;
          while s[b]<>'X' do
            begin
              inc(b);
              if b=26 then break;
            end;
          if (b<25)and(length(s)>0) then
            begin
              while s[b]='X' do
                begin
                  inc(b);
                  if b=25 then
                    begin
                      min:=0;
                      czy:=true;
                      break;
                    end;
                end;
              if b<25 then
                while s[b]<>'X' do
                  begin
                    inc(b);
                    inc(c);
                    if b=26 then
                      begin
                        min:=0;
                        czy:=true;
                        break;
                      end;
                  end;
              if min>c then min:=c;
              wyn[a]:=c;
            end
        end;
      suma:=0;
      for b:=1 to il do
        if wyn[b]>0 then
          suma:=suma+wyn[b]-min;
      if not czy then writeln(suma) else writeln('0');
      readln(il);
    end;
end.
Or give a dificolt input

Help me!!!!!!
lky
New poster
Posts: 21
Joined: Fri Dec 05, 2003 5:59 pm
Contact:

414 - Machined Surfaces

Post by lky »

this is my source code.......
program void;
{uses wincrt;}
var table:array[1..12,1..25]of char;
n,i,j,total,min,row,result:integer;
begin
readln(n);
while n<>0 do
begin
min:=26;
result:=0;
for i:=1 to n do
begin
for j:=1 to 25 do
read(table[i,j]);
readln
end;
for i:=1 to n do
begin
total:=0;
for j:=1 to 25 do
if table[i,j]='B'
then total:=total+1;
if total<min
then begin
min:=total;
row:=i
end
end;
for i:=1 to n do
if i<>row then
begin
total:=0;
for j:=1 to 25 do
if table[i,j]='B'
then total:=total+1;
result:=result+total-min
end;
writeln(result);
readln(n)
end
end.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

Hi Iky,

This problem is very easy and straight forward. So instead of posting your code try to ask for the part you don't understand or confused about.
In this way you will get much more help. :)
lky
New poster
Posts: 21
Joined: Fri Dec 05, 2003 5:59 pm
Contact:

Post by lky »

in fact , i hv tried many test cases and all seem correct.......don't know what is wrong
lky
New poster
Posts: 21
Joined: Fri Dec 05, 2003 5:59 pm
Contact:

Post by lky »

in fact , i hv tried many test cases and all seem correct.......don't know what is wrong
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

Hi Iky,
Remember, in the judge's input 'B' will not represent space.
:wink:
lky
New poster
Posts: 21
Joined: Fri Dec 05, 2003 5:59 pm
Contact:

Post by lky »

tks very much........
deena sultana
New poster
Posts: 36
Joined: Mon Jun 19, 2006 5:43 pm
Location: Bangladesh
Contact:

414 WA, need help!

Post by deena sultana »

Hi!
i got WA in 414. :(
i think, the problem is not clear 2 me.
can anyboby describe me d problem.
There will never be more than a single blank region in any row.
i dont understant d above line of the problem descrip tion.

Here is my code also.

Code: Select all


Any suggestion plz........
Last edited by deena sultana on Thu Jun 22, 2006 8:58 pm, edited 1 time in total.
asif_rahman0
Experienced poster
Posts: 209
Joined: Sun Jan 16, 2005 6:22 pm

Post by asif_rahman0 »

Miss dena,
;)
what you have done when N=1:(!!!!!!!!!!!

Code: Select all

.....
      if(num==0) 
         break; 
      else if(num==1) 
         cout<<0<<endl;    [b]"dont take Input yet before print OUPUT "[/b]
      else 
      { 
         int count=0; 
         loop=num; 
         while(loop--) 
         { 
            gets(str); [b]" you done it heer" ...:)[/b]
....
 
Post Reply

Return to “Volume 4 (400-499)”