Pagini recente » Cod sursa (job #1437039) | Cod sursa (job #1437774) | Cod sursa (job #1563629) | Cod sursa (job #1333820) | Cod sursa (job #182603)
Cod sursa(job #182603)
#include<stdio.h>
#include<algorithm>
int n,nr,v[36001],r;
char a[36001][16];
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[16]={0};
fgets(c,20,stdin);
int i;
for(i=0; (c[i]!='\n')&&(c[i]!='\0'); 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++;
n--;
for(i=1; i<n; i++)
{
ok1=ok2;
ok2=vezi(v[i],v[i+1]);
if((ok1)&&(ok2))
r++;
}
if(ok2)
r++;
printf("%d\n",r);
return 0;
}