10602 - Editor Nottoobad
Moderator: Board moderators
-
- New poster
- Posts: 8
- Joined: Tue Oct 01, 2002 3:22 pm
10602 - Editor Nottoobad
Can anybody give me some hint
thx.
thx.
-
- Experienced poster
- Posts: 187
- Joined: Wed Dec 11, 2002 2:03 pm
- Location: Mount Papandayan, Garut
-
- Experienced poster
- Posts: 146
- Joined: Sat Apr 26, 2003 2:51 am
-
- New poster
- Posts: 8
- Joined: Tue Oct 01, 2002 3:22 pm
I don't understand your meaning clearly, could you talk more detail ?horape wrote:Cost is the number of keys should need to type, so better not to delete any letter you'll need later. You want to group the words that have common letters at the start. Sort by # of common letters with the first word and then lexicographically (sp?)
Saludos,
HoraPe
Let's see if an example makes it clearer:windows2k wrote:I don't understand your meaning clearly, could you talk more detail ?horape wrote:Cost is the number of keys should need to type, so better not to delete any letter you'll need later. You want to group the words that have common letters at the start. Sort by # of common letters with the first word and then lexicographically (sp?)
Saludos,
HoraPe
Code: Select all
abcdef
aasda 1
aafgh 1
abcjkl 3
ghy 0
aafyy 1
abcghj 3
uiop 0
Code: Select all
abcdef
abcjkl 3
abcghj 3
aafgh 1
aafyy 1
aasda 1
ghy 0
uiop 0
Saludos,
HoraPe
Good idea.
Good idea HoraPe!.
I think it'll make things work faster.
Will work on it now.
_.B._
http://online-judge.uva.es/cgi-bin/Onli ... Info:42085
I think it'll make things work faster.
Will work on it now.
_.B._
http://online-judge.uva.es/cgi-bin/Onli ... Info:42085
Always WA
Why I got WA.Please check my code.
Code: Select all
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct T
{
char str[105];
int value;
}s[105];
int sfunc(void const *a,void const *b)
{
T p,q;
int l1,l2;
p=*(T *)a;
q=*(T *)b;
l1=strlen(p.str);
l2=strlen(q.str);
if(p.value==q.value)
{
if(l1==l2) return (strcmp(q.str,p.str));
return (l2-l1);
}
return (q.value-p.value);
}
void main()
{
int testcase,N,i,l,l1,l2,k1,k2,c,count;
char str[105];
//freopen("10602.in","r",stdin);
scanf("%d",&testcase);
while(testcase--)
{
scanf("%d",&N);
scanf("%s",str);
l=strlen(str);
strcpy(s[0].str,str);
s[0].value=l;
for(i=1;i<N;i++)
{
scanf("%s",str);
strcpy(s[i].str,str);
l1=strlen(str);
k1=k2=count=0;
while((s[0].str[k1]==s[i].str[k2]) && k1<l && k2<l1)
{
count++;
k1++;
k2++;
}
s[i].value=count;
}
qsort(s,N,sizeof(s[0]),sfunc);
count=s[0].value;
for(i=1;i<N;i++)
{
l1=strlen(s[i-1].str);
l2=strlen(s[i].str);
k1=k2=c=0;
while((s[i-1].str[k1]==s[i].str[k2]) && k1<l1 && k2<l2)
{
k1++;
k2++;
c++;
}
count+=(l2-c);
}
printf("%d\n",count);
for(i=0;i<N;i++) printf("%s\n",s[i].str);
}
}
10602 Editor Nottobad, Any Critical I/O ?
I always got W.A. Is there any critical I/O ?
Here's my code:
[AC, code deleted]
Here's my code:
[AC, code deleted]
-
- Experienced poster
- Posts: 154
- Joined: Sat Apr 17, 2004 9:34 am
- Location: EEE, BUET