Page 1 of 2

10602 - Editor Nottoobad

Posted: Thu Jan 29, 2004 9:53 am
by DreamLinuxer
Can anybody give me some hint
thx.

Posted: Thu Jan 29, 2004 2:38 pm
by Dmytro Chernysh
Sorting...

Posted: Thu Jan 29, 2004 3:31 pm
by windows2k
Dmytro Chernysh wrote:Sorting...
Could you give more hints?

Posted: Thu Jan 29, 2004 3:48 pm
by titid_gede
greedy :D

Posted: Thu Jan 29, 2004 3:53 pm
by Dmytro Chernysh
Who or what? Me or the algorithm? :D

Posted: Thu Jan 29, 2004 5:40 pm
by DreamLinuxer
Dmytro Chernysh wrote:Who or what? Me or the algorithm? :D
algorithm :)

Posted: Thu Jan 29, 2004 6:15 pm
by windows2k
titid_gede wrote:greedy :D
I also use greedy and get wrong answer.
what is your greedy algorithm?

Posted: Thu Jan 29, 2004 6:23 pm
by horape
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

Posted: Thu Jan 29, 2004 7:07 pm
by windows2k
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
I don't understand your meaning clearly, could you talk more detail ?

Posted: Thu Jan 29, 2004 7:15 pm
by horape
windows2k wrote:
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
I don't understand your meaning clearly, could you talk more detail ?
Let's see if an example makes it clearer:

Code: Select all

abcdef
aasda   1
aafgh   1
abcjkl  3
ghy     0
aafyy   1
abcghj  3
uiop    0
abcdef is the first word, order by number or common letters with it (the number at the right of the words) and break ties lexicographycally.

Code: Select all

abcdef
abcjkl     3
abcghj     3
aafgh      1
aafyy      1
aasda      1
ghy        0
uiop       0
Is it clearer now?

Saludos,
HoraPe

Good idea.

Posted: Sat Mar 20, 2004 9:15 pm
by _.B._
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

Always WA

Posted: Sat Apr 17, 2004 2:08 am
by rasel04
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 ?

Posted: Thu Jun 17, 2004 8:34 pm
by bmouse001
I always got W.A. Is there any critical I/O ?
Here's my code:

[AC, code deleted]

Posted: Mon Jul 19, 2004 9:37 pm
by Mohammad Mahmudur Rahman
I am repeatedly getting WA in this problem but finally failed to figure out the reason. My code is as follows -
[cpp]

//AC. Code deleted
[/cpp]

Can anyone give me some tricky I/O please ?

Posted: Tue Oct 12, 2004 11:12 pm
by Noim
check for this input and output:
input:
1
2
ab
abc
output:
  • 3
    ab
    abc