Cod sursa(job #1254515)

Utilizator costty94Duica Costinel costty94 Data 2 noiembrie 2014 20:38:27
Problema Restante Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

char s[40000][20], aux[20];
int i, n, r, j, k;

int main()
{
	freopen("restante.in", "r", stdin);
	freopen("restante.out", "w", stdout);

	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s", s[i]);
		r = strlen(s[i]);
		sort(s[i], s[i] + n);
	}
	for(i = 0; i < n-1; i++)
	{
		for(j = i+1; j < n; j++)
			if(strcmp(s[i], s[j]) > 0)
			{
				strcpy(aux, s[i]);
				strcpy(s[i], s[j]);
				strcpy(s[j], aux);
			}
	}
	if(strcmp(s[0], s[1]) != 0)
		k++;
	if(strcmp(s[n-1], s[n-2]) != 0)
		k++;
	for(i = 1; i < n-1; i++)
		if(strcmp(s[i], s[i-1]) != 0 && strcmp(s[i+1], s[i]) != 0)
			k++;
	printf("%d", k);
		
	return 0;
}