Cod sursa(job #3371750)

Utilizator bogdy23Copilau Bogdan Mihai bogdy23 Data 31 octombrie 2026 14:02:54
Problema Restante Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <bits/stdc++.h>
#include <fstream>
#include <string>

using namespace std;

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

int main()
{
    int n, i, j, nr = 0;
    char s[36005][20], c[20];

    f >> n;

    for (i = 0; i < n; i++)
    {
        f >> s[i];

        sort(s[i], s[i] + strlen(s[i]));
    }

    for (i = 0; i < n - 1; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (strcmp(s[i], s[j]) > 0)
            {
                strcpy(c, s[i]);
                strcpy(s[i], s[j]);
                strcpy(s[j], c);
            }
        }
    }

    for (i = 0; i < n; i++)
    {
        bool unic = true;

        if (i > 0 && strcmp(s[i], s[i - 1]) == 0)
        {
            unic = false;
        }

        if (i < n - 1 && strcmp(s[i], s[i + 1]) == 0)
        {
            unic = false;
        }

        if (unic)
        {
            nr++;
        }
    }

    g << nr;

    return 0;
}