11530 - SMS Typing

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

Moderator: Board moderators

ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

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

Post by ruhul_sust » Fri Oct 22, 2010 2:50 pm

I m new in uva forum.Next time i'll follow ur advise. Thanks 4 ur advise.

But I m still in problem with this easy problem.I could not find any solution in any previous post .
I m frustrated :0
please help me.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

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

Post by sohel » Sat Oct 23, 2010 8:57 am

gets() after scanf() will not work.

ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

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

Post by ruhul_sust » Wed Oct 27, 2010 7:54 pm

i can't understand what u say.
gets() does not do any work means ?????

I try scanf rather using gets() but still WA!!!!
:(((((
hELp ME ... :'( :( :( :( :(

ruhul_sust
New poster
Posts: 5
Joined: Tue Jul 27, 2010 8:01 pm

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

Post by ruhul_sust » Wed Oct 27, 2010 10:26 pm

thanks I got my Error and i fix it now && got AC....... :D :) :lol:

Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

Re: 11530 - sms typing -- Why WA???? Please help me

Post by Mizanur Rahman(IUK) » Mon Dec 06, 2010 9:08 pm

Code: Select all

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

int main()
{
	long int i,n,count;
	char a;
	cin>>n;
	for(i=0;i<n;i++)
	{
		count=0;
		a=getchar();
		while(a!='\n')
		{
			if(a=='a'||a=='d'||a=='g'||a=='j'||a=='m'||a=='p'||a=='t'||a=='w'||a==' ')
				count=count+1;
			else if(a=='b'||a=='e'||a=='h'||a=='k'||a=='n'||a=='q'||a=='u'||a=='x')
				count=count+2;
			else if(a=='c'||a=='f'||a=='i'||a=='l'||a=='o'||a=='r'||a=='v'||a=='y')
				count=count+3;
			else if(a=='s'||a=='z')
				count=count+4;
			a=getchar();
		}
		printf("Case #%ld: %ld\n",i+1,count);
		//cout<<"Case #"<<i+1<<": "<<count;
		//cout<<endl;
	}
	return 0;
}

anik.bit0104
New poster
Posts: 6
Joined: Thu Sep 23, 2010 1:50 pm
Location: Dhaka, Bangladesh

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

Post by anik.bit0104 » Tue May 03, 2011 3:43 pm

Code: Select all

#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

int posFinder(char c);

int main()
{
  int numOfTestCases;
  string s;
  int sumOfPos=0;
  int caseCounter=0;
  char dummy;

 scanf("%d%c",&numOfTestCases,&dummy);

  for (int i=0;i<numOfTestCases ;i++ )
    {
      caseCounter++;

      getline(cin,s);

      for (int i=0;i<s.size() ;i++ )
        {
          sumOfPos=sumOfPos+posFinder(s[i]);
        }
        cout<<"Case #"<<caseCounter<<": "<<sumOfPos<<endl;
        sumOfPos=0;

    }

  return 0;
}

int posFinder(char c)
{

  char one[8]={'a','d','g','j','m','p','t','w'};
  char two[8]={'b','e','h','k','n','q','u','x'};
  char three[8]={'c','f','i','l','o','r','v','y'};
  char four[2]={'s','z'};

  if (strchr(one,c)!=NULL || c==' ') return 1;
  else if (strchr(two,c)!=NULL) return 2;
  else if (strchr(three,c)!=NULL) return 3;
  else if (strchr(four,c)!=NULL) return 4;

}
I don't know where am i failing.. help me?

zahid0055
New poster
Posts: 1
Joined: Tue Apr 03, 2012 12:43 pm

11530 help

Post by zahid0055 » Tue Apr 03, 2012 12:58 pm

Help me finding the error of my code

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
    char s[101];
    int t,i,j,count=0;
    scanf("%d\n",&t);

    for(i=0;i<t;i++)
    {

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

    return 0;
}
getting Wrong Answer
Help me with some test cases

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11530 help

Post by brianfry713 » Wed Apr 04, 2012 1:28 am

Input:

Code: Select all

3

welcome to ulab
good luck and have fun
AC output:

Code: Select all

Case #1: 0
Case #2: 29
Case #3: 41
Check input and AC output for thousands of problems on uDebug!

EROR
New poster
Posts: 1
Joined: Sun Oct 21, 2012 6:07 pm

Re: 11530

Post by EROR » Sun Oct 21, 2012 6:16 pm

In the Problem Statement here http://uva.onlinejudge.org/index.php?op ... oblem=2525 there is a line containing
Each line will contain at least 1 and at most 100 characters.
. But in the input there may be some inputs where the string is blank. may be one of blank string starts the input file. Can the site update this problems.......??????????
:oops:

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

WA: 11530 Why????

Post by me33 » Tue Feb 25, 2014 9:18 pm

I think everything is okay. but continuously getting WA.
plz help me. :( :cry:

my code.

Code: Select all

Removed After AC
Last edited by me33 on Fri Feb 28, 2014 9:20 pm, edited 3 times in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA: 11850

Post by brianfry713 » Tue Feb 25, 2014 9:41 pm

That doesn't look like the correct problem number
Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

Re: WA: 11530 Why????

Post by me33 » Wed Feb 26, 2014 4:14 pm

Sorry! My mistake.

The problem number is 11530

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA: 11530 Why????

Post by brianfry713 » Thu Feb 27, 2014 12:42 am

Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

Re: WA: 11530 Why????

Post by me33 » Fri Feb 28, 2014 1:43 am

How can I take input in this loop???
Plz help

jaime21
New poster
Posts: 6
Joined: Wed Apr 09, 2014 4:36 pm

Re: 11530 - SMS Typing

Post by jaime21 » Wed Apr 09, 2014 4:39 pm

Hello! I need help!! UVA keeps telling me runtime error! Can't find the bug

Code: Select all

import java.util.*;

class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i, tc, j, sum;
		char c;
		String input;
		
		tc = sc.nextInt();
		sc.nextLine();
		sc.nextLine();
		for(i=1; i<=tc; i++){
			input = sc.nextLine();
			sum = 0;
			for(j=0; j<input.length(); j++){
				c = input.charAt(j);
				if( c=='a' || c=='d' || c=='g' || c=='j' || c=='m' || c=='p' || c=='t' || c=='w' || c==' ' ){
					sum += 1;
				}
				else if( c=='b' || c=='e' || c=='h' || c=='k' || c=='n' || c=='q' || c=='u' || c=='x' ){
					sum += 2;
				}
				else if( c=='c' || c=='f' || c=='i' || c=='l' || c=='o' || c=='r' || c=='v' || c=='y' ){
					sum += 3;
				}
				else if( c=='s' || c=='z' ){
					sum += 4;
				}
			}
			System.out.format("Case #%d: %d\n", i, sum);
		}
}
	
}

Post Reply

Return to “Volume 115 (11500-11599)”