Cod sursa(job #2556284)

Utilizator Florinos123Gaina Florin Florinos123 Data 24 februarie 2020 19:49:36
Problema Restante Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <fstream>
#include <algorithm>
#include <cstring>

using namespace std;

ifstream f ("restante.in");
ofstream g ("restante.out");

int n, i, j, lg, rez, poz[36000];
char a[36000][20], s[20];

bool cmp (int x, int y)
{
    if (strcmp(a[x], a[y]) < 0)
        return true;
    return false;
}

int main()
{
  f >> n;
  f.get();
   for (i=1; i<=n; i++)
   {
       f.getline(s, sizeof(s));
       lg = strlen(s), sort(s, s+lg);
       strcpy(a[i], s);
   }

   for (i=1; i<=n; i++)
      poz[i] = i;

   sort(poz+1, poz+n+1, cmp);

   for (i=1; i<=n; i++)
   {
      j = i;
       while (strcmp(a[j], a[j+1]) == 0 && j+1 <= n)
        j ++;
      if (i == j)
        rez ++;
      i = j;
   }
  g << rez;
    return 0;
}