Cod sursa(job #2014106)

Utilizator DruffbaumPopescu Vlad Druffbaum Data 22 august 2017 21:42:31
Problema Restante Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>

const int MAXN = 3e4 + 6e3;

char c[18];
std::string s[MAXN + 1];

int main() {
  int n, ans, p;
  freopen("restante.in", "r", stdin);
  scanf("%d", &n);
  p = 0;
  for (int i = 0; i < n; ++i) {
    gets(c);
    std::sort(c, c + strlen(c));
    s[++p] = c;
  }
  std::sort(s + 1, s + 1 + p);
  ans = 0;
  --p;
  for (int i = 2; i < p; ++i) {
    if (s[i - 1] != s[i] && s[i] != s[i + 1]) {
      ++ans;
    }
  }
  if (s[1] != s[2]) {
    ++ans;
  }
  if (s[p] != s[p + 1]) {
    ++ans;
  }
  FILE *fout = fopen("restante.out", "w");
  fprintf(fout, "%d\n", ans);
  fclose(fout);
  return 0;
}