Cod sursa(job #315969)
Utilizator | Data | 17 mai 2009 19:57:09 | |
---|---|---|---|
Problema | Restante | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 2.03 kb |
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define dim 36500
int n,i,k,m,nr;
char a[dim][17];
void sort1(int st,int dr,char a[17])
{
int i=st,j=dr;
char p=a[(st+dr)/2],aux;
do
{
while(a[i]<p)
i++;
while(a[j]>p)
j--;
if(i<=j)
{
aux=a[i];
a[i]=a[j];
a[j]=aux;
i++;
j--;
}
}
while(i<=j);
if(st<j)
sort1(st,j,a);
if(i<dr)
sort1(i,dr,a);
}
void sort2(int st,int dr)
{
int i=st,j=dr;
char b[17],aux[17];
strcpy(b,a[(st+dr)/2]);
do
{
while(strcmp(a[i],b)<0)
i++;
while(strcmp(a[j],b)>0)
j--;
if(i<=j)
{
strcpy(aux,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],aux);
i++;
j--;
}
}
while(i<=j);
if(st<j)
sort2(st,j);
if(i<dr)
sort2(i,dr);
}
void read()
{
scanf("%d",&n);
gets(a[1]);
for(i=1;i<=n;i++)
{
gets(a[i]);
sort1(0,strlen(a[i])-1,a[i]);
// printf("%s\n",a[i]);
}
sort2(1,n);
}
void solve()
{
for(i=1;i<=n;i++)
{
// printf("%d %d %s %d\n",i,strcmp(a[i-1],a[i]),a[i],nr);
if((strcmp(a[i-1],a[i]) ||i-1==0) && ( strcmp(a[i+1],a[i]) || i==n))
nr++;
}
printf("%d",nr);
}
int main ()
{
freopen("restante.in","r",stdin);
freopen("restante.out","w",stdout);
read();
solve();
return 0;
}