Cod sursa(job #656149)

Utilizator daniel.dumitranDaniel Dumitran daniel.dumitran Data 3 ianuarie 2012 23:58:21
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <string>
#include <map>
#include <algorithm>

#define FISIN   "restante.in"
#define FISOUT  "restante.out"

typedef std::map<std::string, int> map_t;

int main() {
  FILE *fin = fopen(FISIN, "rt");
  FILE *fout = fopen(FISOUT, "wt");

  char buffer[32];
  int n;
  map_t m;

  fscanf(fin, "%d", &n);
  for (int i = 0; i < n; ++i) {
    fscanf(fin, "%s", buffer);
    std::string s(buffer);
    std::sort(s.begin(), s.end());
    ++m[s];
  }

  int result = 0;
  for (map_t::const_iterator it = m.begin(); it != m.end(); ++it) {
    if (it->second == 1)
      ++result;
  }

  fprintf(fout, "%d\n", result);

  fclose(fout);
  fclose(fin);
  return 0;
}