Cod sursa(job #1782350)

Utilizator depevladVlad Dumitru-Popescu depevlad Data 17 octombrie 2016 23:53:27
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int kMaxN = 36005;
const int kLength = 50;

int n;
char b[kLength];
vector <int> c[kMaxN];

int main() {
    freopen("restante.in", "r", stdin);
    freopen("restante.out", "w", stdout);
    
    scanf("%d\n", &n);
    for (int i = 1; i <= n; i++) {
        c[i] = vector <int>(27, 0);
        gets(b);
        for (int j = 0; j < strlen(b); j++) 
            c[i][b[j] - 'a']++;
    }
    
    sort(c + 1, c + n + 1);
    
    int goodCount = 0;
    int i = 1;
    while (i <= n) {
        int j = i;
        while (j <= n && c[j] == c[i]) j++;
        goodCount += (j - i == 1);
        i = j;
    }
    
    printf("%d\n", goodCount);
    return 0;
}