Page 1 of 3

11530 - SMS Typing

Posted: Tue Oct 21, 2008 11:14 pm
by naffi
I am frustrated about this easy problem. WA and WA, but can not find the error. Can anybody help me? Is there any critical IO?

Re: WA: 11530: SMS Typing

Posted: Wed Oct 22, 2008 2:51 am
by mmonish
try this case..
Input:

Code: Select all

1
  a
Output:

Code: Select all

Case #1: 3
hope this helps..

Re: WA: 11530: SMS Typing

Posted: Wed Oct 22, 2008 1:33 pm
by naffi
Thanks, :). I got my problem and got AC.

Re: WA: 11530: SMS Typing

Posted: Tue Nov 18, 2008 3:22 pm
by Bitta
I am getting WA.Plz help me...

Code: Select all

#include<stdio.h>

int main()
{
	char s[103];
	int i,cnt,tc,n;

	scanf("%d",&tc);

	n=1;

	while(tc>0)
	{	
		fflush(stdin);
		gets(s);

		cnt=0;
		for(i=0;s[i];i++)
		{
			if(s[i]=='a' || s[i]=='d' || s[i]=='g' || s[i]=='j' || s[i]=='m' || s[i]=='p' || s[i]=='t' || s[i]=='w' || s[i]==' ')
			{
				cnt+=1;
			}

			else if(s[i]=='b' || s[i]=='e' || s[i]=='h' || s[i]=='k' || s[i]=='n' || s[i]=='q' || s[i]=='u' || s[i]=='x')
			{
				cnt+=2;
			}

			else if(s[i]=='c' || s[i]=='f' || s[i]=='i' || s[i]=='l' || s[i]=='o' || s[i]=='r' || s[i]=='v' || s[i]=='y')
			{
				cnt+=3;
			}

			else if(s[i]=='s' || s[i]=='z')
			{
				cnt+=4;
			}
		}

		printf("Case #%d: %d\n",n,cnt);
		n++;
		tc--;
		
	}

	return 0;
}


Re: WA: 11530: SMS Typing

Posted: Wed Nov 19, 2008 1:00 pm
by shamim
Just add a dummy gets after you take the number of cases as input and remove the fflush().

This should get your code AC :wink:

Re: WA: 11530: SMS Typing

Posted: Sat Mar 21, 2009 11:34 am
by apurba
shamim wrote:Just add a dummy gets after you take the number of cases as input and remove the fflush().

This should get your code AC :wink:

Code: Select all

thanks a lot.........

Re: 11530 - SMS Typing

Posted: Wed Apr 15, 2009 12:36 pm
by aum
Hi everyone,

I am getting WA in this problem. This is how i accept the input

Code: Select all

# include <iostream>
# include <string>

using namespace std;

int main()
{
    int t,c = 0;
    cin>>t;
   
    //do something here
    
    fflush(stdin);
    string inp;
    
    while(t--)
    {
        getline(cin,inp);

        //do something here        

        cout<<"Case #"<<++c<<": "<<res<<endl;
    }
    
 return 0;   
}

I am sure that my algorithm is correct. i think i am getting WA because i am not accepting input properly.
Please help.

Re: 11530 - SMS Typing

Posted: Wed Apr 15, 2009 4:28 pm
by mf
fflush(stdin) doesn't do anything.

Insert another getline right after cin>>t to eat a newline character.

Re: 11530 - SMS Typing

Posted: Sun Sep 13, 2009 1:47 pm
by nazmuldiu
Why My code getting WA please?

Code: Select all

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int n[26]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
    char b[150];
    int a=0,t;

    cin>>t;
    for(int j=0;j<t;j++)
    {
        a=0;
		getchar();
        gets(b);
        for(int i=0;b[i];i++)
        {
            if(b[i]==32)
                a++;
            else
                a+=n[b[i]-'a'];

        }
        cout<<"Case #"<<j<<": "<<a<<endl;
    }
    return 0;
}

Re: 11530 - SMS Typing

Posted: Sun Sep 13, 2009 8:49 pm
by saiful_sust
Hello nazmul..........
just change this line:

Code: Select all

 cout<<"Case #"<<j<<": "<<a<<endl;
To:

Code: Select all

 cout<<"Case #"<<j+1<<": "<<a<<endl;
:lol: :lol: :lol:
  • IMPOSSIBLE MEANS I M POSSIBLE

Re: 11530 - SMS Typing

Posted: Tue Sep 15, 2009 9:28 am
by samin_yasar

Code: Select all

#include <stdio.h>

int main()
{
	int test;
	char str[100];
        scanf("%d",&test);
	//fflush(stdin);
	for(int i=0;i<test;i++)
	{
		gets(str);

		int j=0,count=0;
		
		while(str[j]!='\0')
		{

if(str[j]==' ')count+=1;
else if(str[j]=='a' || str[j]=='d' || str[j] == 'g' || str[j] =='j' || str[j]=='m' || str[j] == 'p' || str[j] == 't' || str[j] =='w')count+=1;
else if(str[j]=='b' || str[j]=='e' || str[j] == 'h' || str[j] =='k' || str[j]=='n' || str[j] == 'q' || str[j] == 'u' || str[j] =='x')count+=2;
else if(str[j]=='c' || str[j]=='f'  || str[j] == 'i' || str[j] =='l' || str[j]=='o' || str[j] == 'r' || str[j] == 'v' || str[j] == 'y')count+=3;
else count+=4;
j++;
}
printf("Case %d: %d\n",i+1,count);
}
return 0;

}
would someone please tell me what is wrong with this code?
i submitted without fflush(stdin).

Re: 11530 - SMS Typing

Posted: Wed Sep 16, 2009 12:34 am
by saiful_sust
Hello samin

change this line

Code: Select all

printf("Case %d: %d\n",i+1,count);
To

Code: Select all

printf("Case #%d: %d\n",i+1,count);
:D :D :D

Re: 11530 - SMS Typing

Posted: Mon Sep 28, 2009 7:42 pm
by Angeh
scanf("%d%d\n",&n,&m) reads not only new line character but leading spaces in second line.
use scanf("%d%d",&n,&m);gets(line) instead ;

11530 - sms typing -- Why WA???? :(

Posted: Wed Oct 20, 2010 10:09 am
by ruhul_sust
//help me to find d ERROR

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

void count(char a[], int x)
{

//scanf("%[ ^\n]", a);

gets(a);
//
// printf("Case #%d: ", x);
int i,length, n, sum=0;
length=strlen(a);
for(i=0; i<length; i++)
{
if(a=='a' || a=='d' || a=='g' || a=='j' || a=='m' || a=='p' || a=='t' || a=='w' || a==' ')
sum+=1;
else if(a=='b' || a[i]=='e' || a[i]=='h' || a[i]=='k' || a[i]=='n' || a[i]=='q' || a[i]=='u' || a[i]=='x')
sum+=2;
else if(a[i]=='c' || a[i]=='f' || a[i]=='i' || a[i]=='l' || a[i]=='o' || a[i]=='r' || a[i]=='v' || a[i]=='y')
sum+=3;
else if (a[i]=='s' || a[i]=='z')
sum+=4;
}
printf("%d\n", sum);
return;
}

int main()
{
char a[500];
int n, i;
scanf(" %d ", &n);
//scanf("\n");
// printf("0000000\n");

for(i=1;i<=n; i++)
{
// gets(a);
printf("Case #%d: ", i);
count(a, i);
}
// while()
return 0;
}

Re: 11530 - sms typing -- Why WA???? :(

Posted: Thu Oct 21, 2010 4:23 am
by sohel
Use the search option located at the top right corner to find existing discussions of the problem.
In the search box, type 11530 and click on the search button next to it - you will find previous discussion on this problem.

Don't create a new thread for a problem that already exists. Make your post in an existing one.

Good Luck and keep solving!