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

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

Post by deena sultana »

oh, hw STUPID i m!

Thank u very much ASIF. i get ac now. i m so happy. :D

take care.
kolpobilashi
Learning poster
Posts: 54
Joined: Mon Jan 02, 2006 3:06 am
Location: Dhaka,Bangladesh
Contact:

Post by kolpobilashi »

:( anyone can say where is my mistake?

Code: Select all

removed after AC
thanx in advance.....
Last edited by kolpobilashi on Tue Aug 15, 2006 10:49 pm, edited 1 time in total.
Sanjana
mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun »

What should be output for the following you think

Code: Select all

2
X                       X
X                       X
kolpobilashi
Learning poster
Posts: 54
Joined: Mon Jan 02, 2006 3:06 am
Location: Dhaka,Bangladesh
Contact:

Post by kolpobilashi »

OOpS!!! its a silly mistake :oops: ......
thanx a lot Mamun bhaia......AC now :D
Sanjana
Lyaxe
New poster
Posts: 3
Joined: Wed Feb 21, 2007 7:02 pm
Location: L

414 WA, could someone help me?

Post by Lyaxe »

this is my code, I'm using c++

Code: Select all

(removed)
I don't find anything wrong in my code, could someone give me an input to prove my code wrong?
Last edited by Lyaxe on Thu Feb 22, 2007 5:03 am, edited 1 time in total.
Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian »

Code: Select all

12
X XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
0
The right result is 1 (obviously). Think: why does your solution output 24 for this case? =).

Please remove your code after reading this post so it doesn't spoil the fun to others.
Lyaxe
New poster
Posts: 3
Joined: Wed Feb 21, 2007 7:02 pm
Location: L

Post by Lyaxe »

thanks a lot, now I realize my mistake :D
Student of Computer Science at Universitas Katolik Parahyangan
AcmNightivy
New poster
Posts: 36
Joined: Tue Dec 04, 2007 10:20 am

414WA..Help

Post by AcmNightivy »

my thought is to find the max num of the 'X', and do sub to find..And i have tested lots of cases..Maybe there is something wrong with my I/0..Help.!

Code: Select all

#include <iostream.h>
#include "string.h"

int main ()
{
	char str[13][26];
	int count[13];
	int row;
	int max;
	int i, j;

	while (cin>>row && row)
	{
		max = 0;
		for (i = 0; i < row; i++)
		{
			cin.get ();
			cin.getline (str[i], 26);	
		}

		for (i = 0; i < row; i++)
		{
			count[i] = 0;
			for (j = 0; str[i][j] != '\0'; j++)
				if (str[i][j] == 'X')
					count[i]++;

			if (count[i] > max)
				max = count[i];
		}

		j = 0;
		for (i = 0; i < row; i++)
			if (count[i] < max)
				j += max - count[i];

		cout<<j<<endl;
	}
	return 0;
}
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Use existing thread.
AcmNightivy
New poster
Posts: 36
Joined: Tue Dec 04, 2007 10:20 am

Post by AcmNightivy »

my thought is to find the max num of the 'X', and do sub to find..And i have tested lots of cases..Help.!

Code: Select all

#include <iostream.h>
#include <stdio.h>
#include "string.h"

int main ()
{
	char str[13][26];
	int count[13];
	int row;
	int max;
	int i, j;

	while (cin>>row && row)
	{
		max = 0;
		for (i = 0; i < row; i++)
		{
			gets (str[i]);	
		}

		for (i = 0; i < row; i++)
		{
			count[i] = 0;
			for (j = 0; str[i][j] != '\0'; j++)
				if (str[i][j] == 'X')
					count[i]++;

			if (count[i] > max)
				max = count[i];
		}

		j = 0;
		for (i = 0; i < row; i++)
			if (count[i] < max)
				j += max - count[i];

		cout<<j<<endl;
	}
	return 0;
}
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 »

Code: Select all

for (i = 0; i < row; i++)
      {
         gets (str[i]);   
      }

      for (i = 0; i < row; i++)
      {
         count[i] = 0;
         for (j = 0; str[i][j] != '\0'; j++)
            if (str[i][j] == 'X')
               count[i]++;

         if (count[i] > max)
            max = count[i];
      } 
this code creates WA.
u can use

Code: Select all

while(1)
{
	scanf("%c",&c);
        check '\n'
	{
	    Array=count;
	    check min(count<max)
		     max=count;
		    break;
	}
	otherwise(c==' ')
		 count++;
}
hope it helps.
''I want to be most laziest person in the world''
deadangelx
New poster
Posts: 32
Joined: Tue Feb 13, 2007 1:31 pm

Post by deadangelx »

this input and output may help you to understand this problem easily

input

Code: Select all

3
XXX  XXXXXXXXXXXXXXXXXXXX
XXXXX  XXXXXXXXXXXXXXXXXX
XXXXXXX  XXXXXXXXXXXXXXXX
3
XXX  XXXXXXXXXXXXXXXXXXXX
XXXXX   XXXXXXXXXXXXXXXXX
XXXXXXX  XXXXXXXXXXXXXXXX
0
output

Code: Select all

0
1
iit2006039
New poster
Posts: 2
Joined: Mon Jun 09, 2008 4:46 pm

Re: 414 WA, need help!

Post by iit2006039 »

Code: Select all

#include<iostream>
#include<cmath>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
#include<algorithm>

using namespace std;
            
int main()
{
int num;
cin>>num;
while(num!=0)
{
 			 string s;
 			 vector<string> arr(num);
 			 getline(cin,s);
 			  for(int i=0;i<num;i++)
 			  getline(cin,arr[i]);
 			  int min=30;
 			  vector<int > mani(num);
			   for(int i=0;i<num;i++)
 			  {
			   		   mani[i]=arr[i].rfind(' ')-arr[i].find(' ');
			   		   if(min>mani[i])
			   		   min=mani[i];
			   }
			   //cout<<min<<endl;
			   int ret=0;
			   for(int i=0;i<num;i++)
			   ret+=mani[i]-min;
  		  	  cout<<ret<<endl;
  		  	  cin>>num;
}           
return 0;
}


somebody please point out the error...:(
aug21st
New poster
Posts: 1
Joined: Sat Jan 24, 2009 11:47 pm

Re: 414 WA, need help!

Post by aug21st »

getting WA
any help!!1
working for sample cases that are available

Code: Select all

#include<stdio.h>
int main()
{
int n;
int min,tot,temp;
int i,j,k,flag=0;
char stemp[25];
scanf("%d",&n);
while(n!=0)
{
	tot=0;
	min=-1;
	for(i=0;i<n;i++)
	{
		scanf("%s",stemp);
		j=0;
		while(stemp[j]!='\0')
			j++;
		if(j==25)
		{
			min=0;
		}
		else
		{
			scanf("%s",stemp);
			k=0;
			while(stemp[k]!='\0')
				k++;
			temp=25-(k+j);
			tot+=temp;
			if(temp<min || min==-1)
				min=temp;
		}
	}
	tot=tot-(n*min);
	if(flag!=0)
		printf("\n");
	printf("%d",tot);
	flag=1;
	scanf("%d",&n);
}
return 0;
}
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 414 WA, need help!

Post by Obaida »

Some one plz help me. I got wa. I am confused about my mistake.

Code: Select all

got acc
try_try_try_try_&&&_try@try.com
This may be the address of success.
Post Reply

Return to “Volume 4 (400-499)”