Page 1 of 4

414

Posted: Fri Apr 12, 2002 4:25 am
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]

Please, give me more sample input&output 414

Posted: Tue Dec 10, 2002 3:41 am
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]

Posted: Fri Jan 03, 2003 12:05 pm
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

Posted: Sun Jan 12, 2003 5:09 am
by E.L
thanx for your help, I got AC now....

Posted: Fri Feb 28, 2003 7:47 am
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

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

Posted: Sun Apr 27, 2003 12:10 am
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]

414-Wa? Why? Please help!

Posted: Mon Oct 06, 2003 7:38 pm
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!!!!!!

414 - Machined Surfaces

Posted: Fri Dec 05, 2003 6:02 pm
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.

Posted: Sat Dec 06, 2003 7:23 am
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. :)

Posted: Sat Dec 06, 2003 8:59 am
by lky
in fact , i hv tried many test cases and all seem correct.......don't know what is wrong

Posted: Sat Dec 06, 2003 9:00 am
by lky
in fact , i hv tried many test cases and all seem correct.......don't know what is wrong

Posted: Sat Dec 06, 2003 11:06 am
by sohel
Hi Iky,
Remember, in the judge's input 'B' will not represent space.
:wink:

Posted: Sat Dec 06, 2003 11:37 am
by lky
tks very much........

414 WA, need help!

Posted: Thu Jun 22, 2006 7:50 pm
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........

Posted: Thu Jun 22, 2006 8:29 pm
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]
....