Page 1 of 3

10393 - The One-Handed Typist

Posted: Tue Nov 19, 2002 10:01 am
by Subeen
easy problem... but got WA :cry:
and can't find the bug.
someone help me plz...
here is my code:
[cpp]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int sort_function( const void *a, const void *b)
{
return( strcmp((char *)a,(char *)b) );
}

void main()
{
char *ara[] = {"", "qaz", "wsx", "edc", "rfvtgb", " ", " ", "yhnujm", "ik,", "ol.", "p;/"};
char in[55];
char word[1001][55];
char ch;
int finger[11];
int n, p;
int i, j, k, l, m, max, len;
int flag, count;

while(2==scanf("%d%d", &p, &n))
{
for(i=1; i<11; i++) finger = 1;

for(i=0; i<p; i++)
{
scanf("%d", &j);
finger[j] = 0;
}

max = 0;
for(i=0; i<n; i++)
{
scanf("%s", in);

flag = 1;
len = strlen(in);
for(j=0; j<len && flag; j++)
{
ch = in[j];
for(k=1; k<=10 && flag; k++)
{
for(l=0; l<strlen(ara[k]); l++)
{
if(ch==ara[k][l])
{
if(!finger[k])
{
flag = 0;
break;
}
}
}
}
}

if(flag)
{
if(len > max)
{
m = 0;
strcpy(word[m++], in);
max = len;
}
else if(len==max)
strcpy(word[m++], in);
}
}

qsort((void *)word, m, sizeof(word[0]), sort_function);

for(i=0, count=0; i<m;)
{
j = i;
while(!strcmp(word, word[j]))
{
count++;
j++;
if(j==m) break;
}
i = j;
count--;
}

count = m - count;

printf("%d\n", count);

for(i=0; i<m; )
{
printf("%s\n", word);
j = i;
while(!strcmp(word, word[j]))
{
j++;
if(j==m) break;
}
i = j;
}
}
}
[/cpp]

Posted: Wed Nov 20, 2002 5:34 am
by rakeb
i think for the input:
3 18
7 8 9
weaves
waxers
waxed
waxen
waxer
waxers
waxes
waxing
waxy
we
wear
wearable
wearer
wearing
wears
weave
weaver
weaves
weaving

output is:
4
waxers
wearer
weaver
weaves
BUT YOUR PROGRAM GIVES:
5
waxers
wearer
weaver
weaves

Posted: Wed Nov 20, 2002 5:39 am
by rakeb
sorry, the first line of input will be 3 19

10393

Posted: Thu Nov 21, 2002 9:28 pm
by yahoo
Can anybody help me in this problem?This problem seemed to be easy to me but i got wrong answer all the time. Is there any typical input in this problem. Can anybody help me with some input so that i can check where i am wrong. if you wish i shall post my code later. :oops:

Posted: Fri Nov 22, 2002 4:19 am
by yatsen
The words in the list should be distinct and occur in alphabetical order.
The inputs may have duplicate words, but the output should be distinct.

sample input:

edcba
abcde
abcde

sample output:

abcde
edcba

10393 - The One-Handed Typist

Posted: Thu Jan 02, 2003 3:36 am
by sidky
Can any one please give me some input and output for this problem?

Tricky case(s) plz...

Posted: Sun Feb 23, 2003 2:24 pm
by raysa
Hi!
I have no idea why I got so many WA's for this <One Handed Typist> prob.
I've handled the blanklines and blankspaces. I did it incorrectly or I shouldn't?
Off course, I've considered the "distinct" and "alphabetical order" things too.
Sample I/O and stuffs seems perfect. Is there any tricky case(s) I missed?
Please lend a hand... Any tips would be appreciated.

Thx,
Raysa

Posted: Thu Feb 27, 2003 11:03 pm
by anupam
i have tried to implement all the advices you all gave,distinct word,ofcourse,
i think there is something very small mistake in my code?
will i post it?
--anupam :oops: :oops: :oops:

10393 Why WA ?????????????

Posted: Tue Apr 01, 2003 8:32 am
by Daredevil
What's wrong with my code ?

C:

#include<stdio.h>
#include<string.h>
int m,n,finger[15],i,j,k,sum,a,in[1010],len1,len;
char word[1010][60],checker[50],list[1010][60];
char letter[15][10]={"qaz","wsx","edc","rfvtgb","!","!","yhnujm","ik,","ol.","p;/"};
void main(){
while(scanf("%i %i",&m,&n)!=EOF){
for(i=0;i<m;i++){
scanf("%i",&finger);
if(finger==5||finger==6){i--;m--;}
}
strcpy(checker,letter[finger[0]-1]);
for(i=1;i<m;i++){strcat(checker,letter[finger-1]);}
for(i=0;i<n;i++){scanf("%s",&word);}
for(i=0,sum=0;i<n;i++){
for(j=0,len=strlen(word);j<len;j++){
for(k=0,len1=strlen(checker);k<len1;k++){
if(word[j]==checker[k]){break;}
}
if(k<len1){break;}
}
if(j==len&&j>=sum){
if(j>sum){sum=j;a=0;in[0]=i;a++;}
else{in[a]=i;a++;}
}
}
for(i=0;i<a;i++){strcpy(list,word[in]);}
for(i=0;i<a-1;i++){
m=i;
for(j=i+1;j<a;j++){
if(strcmp(list[j],list[m])<0){m=j;}
}
if(m!=i){strcpy(checker,list[m]);strcpy(list[m],list);strcpy(list[i],checker);}
}
printf("%i\n",a);
for(i=0;i<a;i++){
printf("%s\n",list[i]);
while(strcmp(list[i],list[i+1])==0&&i<a){i++;}
}
}
}

First, I put all of the characters that can't be typed in the variable checker,
then I scan the words character per character and compare it to those in the checker. If it matches, I skip to the next word and so on.
After selecting suitable words, they are sorted and printed out (where the same words are skipped).

10393 - my mistake or Judge's bug?

Posted: Thu Jun 05, 2003 5:12 am
by Dmytro Chernysh
I guess, I did everything according to the problem's description, but WA.
Can somebody post tricky input?

Or maybe it's again Judge's bug???

Posted: Thu Jun 05, 2003 7:48 am
by Dominik Michniewski
I solve this problem with one atempt, so I think that it's mistake by your side ...

Best regards
DM

Posted: Thu Jun 05, 2003 5:37 pm
by Dmytro Chernysh
I meant by "bug" - is the decription of the problem absolutelly clear?
If so, I don't know where is my mistake... :-(

Can you please post some inputs/outputs. Sure, the more the better :-)

There are some bugs in the decriptions of the Judge's problems, like 10194(unclear description), 10323 (nagetive factorial :-) )

Posted: Thu Jun 05, 2003 10:52 pm
by the LA-Z-BOy
Are you guessing that F and N are on a line and the handicap list are on the second line for each Test Cases..? This might not be true, because when i considered this i got WA. Anyway if so, then the input might look like this

Code: Select all

5 5
6
7 8
9 10
the
stewardesses
have
funny
hair

Posted: Fri Jun 06, 2003 1:04 am
by Dmytro Chernysh
The answer for the input is 0, isn't it?

Posted: Fri Jun 06, 2003 1:07 am
by Dmytro Chernysh
Thanks to everyone, I got AC.

But like I said, such "tricks" only disgrace the Judge...