Pagini recente » Cod sursa (job #2257745) | Cod sursa (job #813550) | Cod sursa (job #2015811) | Cod sursa (job #827294) | Cod sursa (job #182633)
Cod sursa(job #182633)
#include<stdio.h>
#include<algorithm>
int n,nr,v[36010],r;
char a[36010][20];
using namespace std;
bool comp(const char &x,const char &y)
{
if(x<y)
return true;
return false;
}
void citeste()
{
char c[20];
char pre[20]={0};
fgets(c,20,stdin);
int i;
for(i=0; (c[i]!='\n')&&(c[i]!='\0')&&(i<16); i++)
pre[i]=c[i];
sort(pre,pre+16,comp);
for(i=0; i<16; i++)
a[nr][i]=pre[i];
v[nr]=nr;
}
bool compar(const int &x,const int &y)
{
int i;
for(i=0; i<16; i++)
if(a[x][i]!=a[y][i])
{
if(a[x][i]<a[y][i])
return true;
return false;
}
return true;
}
inline int vezi(int x,int y)
{
int i;
for(i=0; i<16; i++)
if(a[x][i]!=a[y][i])
return 1;
return 0;
}
int main()
{
freopen("restante.in","r",stdin);
freopen("restante.out","w",stdout);
int i,ok1,ok2;
scanf("%d\n",&n);
for(nr=0; nr<n; nr++)
citeste();
sort(v,v+n,compar);
ok2=vezi(v[0],v[1]);
if(ok2)
r++;
for(i=1; i<n-1; i++)
{
ok1=ok2;
ok2=vezi(v[i],v[i+1]);
if((ok1)&&(ok2))
r++;
}
if(ok2)
r++;
printf("%d\n",r);
return 0;
}