10393 - The One-Handed Typist

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

Moderator: Board moderators

Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

10393 - The One-Handed Typist

Post by Subeen » Tue Nov 19, 2002 10:01 am

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]

User avatar
rakeb
New poster
Posts: 42
Joined: Fri Aug 30, 2002 2:51 pm
Location: France

Post by rakeb » Wed Nov 20, 2002 5:34 am

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

User avatar
rakeb
New poster
Posts: 42
Joined: Fri Aug 30, 2002 2:51 pm
Location: France

Post by rakeb » Wed Nov 20, 2002 5:39 am

sorry, the first line of input will be 3 19

User avatar
yahoo
Learning poster
Posts: 93
Joined: Tue Apr 23, 2002 9:55 am

10393

Post by yahoo » Thu Nov 21, 2002 9:28 pm

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:

yatsen
Learning poster
Posts: 68
Joined: Fri Nov 23, 2001 2:00 am
Location: taiwan

Post by yatsen » Fri Nov 22, 2002 4:19 am

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

sidky
New poster
Posts: 50
Joined: Wed Nov 06, 2002 1:37 pm
Location: Planet Earth, Universe
Contact:

10393 - The One-Handed Typist

Post by sidky » Thu Jan 02, 2003 3:36 am

Can any one please give me some input and output for this problem?

raysa
New poster
Posts: 40
Joined: Wed Dec 18, 2002 4:23 pm
Location: Indonesia

Tricky case(s) plz...

Post by raysa » Sun Feb 23, 2003 2:24 pm

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

anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam » Thu Feb 27, 2003 11:03 pm

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:
"Everything should be made simple, but not always simpler"

Daredevil
New poster
Posts: 19
Joined: Tue Apr 01, 2003 7:47 am
Location: Earth

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

Post by Daredevil » Tue Apr 01, 2003 8:32 am

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).

Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

10393 - my mistake or Judge's bug?

Post by Dmytro Chernysh » Thu Jun 05, 2003 5:12 am

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???

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Thu Jun 05, 2003 7:48 am

I solve this problem with one atempt, so I think that it's mistake by your side ...

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

Post by Dmytro Chernysh » Thu Jun 05, 2003 5:37 pm

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 :-) )

User avatar
the LA-Z-BOy
Learning poster
Posts: 94
Joined: Wed Jul 31, 2002 12:44 pm
Location: Dacca, Bangladesh
Contact:

Post by the LA-Z-BOy » Thu Jun 05, 2003 10:52 pm

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
Istiaque Ahmed [the LA-Z-BOy]

Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

Post by Dmytro Chernysh » Fri Jun 06, 2003 1:04 am

The answer for the input is 0, isn't it?

Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

Post by Dmytro Chernysh » Fri Jun 06, 2003 1:07 am

Thanks to everyone, I got AC.

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

Post Reply

Return to “Volume 103 (10300-10399)”