Mai intai trebuie sa te autentifici.
Cod sursa(job #130164)
Utilizator | Data | 31 ianuarie 2008 14:16:18 | |
---|---|---|---|
Problema | Restante | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.9 kb |
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
using namespace std;
const int L_MAX = 20;
const int N_MAX = 36010;
char cuv[L_MAX];
string words[N_MAX];
int frecv[32];
int main()
{
freopen("restante.in", "r", stdin);
#ifndef _SCREEN_
freopen("restante.out", "w", stdout);
#endif
int N, i, L, j, k;
char c;
scanf("%d\n", &N);
for (i = 1; i <= N; i ++) {
scanf("%s ", cuv);
L = strlen(cuv);
memset(frecv, 0, sizeof(frecv));
for (j = 0; j < L; j ++) {
frecv[cuv[j] - 'a'] ++;
}
for (c = 'a'; c <= 'z'; c ++) {
if (frecv[c - 'a']) {
for (k = 1; k <= frecv[c - 'a']; k ++) {
words[i].push_back(c);
}
}
}
}
sort(words + 1, words + N + 1);
int rez = 0;
for (i = 2; i < N; i ++) {
if (words[i] != words[i - 1] && words[i] != words[i + 1]) {
rez ++;
}
}
if (words[N] != words[N - 1]) rez ++;
printf("%d\n", rez);
return 0;
}