Cod sursa(job #1213233)

Utilizator hopingsteamMatraguna Mihai-Alexandru hopingsteam Data 27 iulie 2014 16:31:14
Problema Restante Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.26 kb
#include    <iostream>
#include    <fstream>
#include    <algorithm>
#include    <cstring>

using namespace std;

ifstream fin("restante.in");
ofstream fout("restante.out");

string word[36005];

void quickSort(int left, int right) 
{
    int i = left, j = right;
    string tmp;
    string pivot = word[(i+j)/2];
    while (i <= j) 
    {
        while(word[i] < pivot)
            i++;
        while(word[j] > pivot)
            j--;
        if (i <= j) 
        {
            tmp = word[i];
            word[i] = word[j];
            word[j] = tmp;
            i++;
            j--;
        }
      };
 
      if (left < j)
            quickSort(left, j);
      if (i < right)
            quickSort(i, right);
}

void read()
{
    int n;
    fin >> n;        
        
    for(int i = 0; i < n; i++)
    {
        fin >> word[i];
        sort(word[i].begin(), word[i].end());
    }
    
    quickSort(0, n-1);
    
    int sol = 0, ord = 0;
    string now;
    for(int i = 0; i < n; i++)
    {
        ord = 0;
        now = word[i];
        while(now == word[i+1])
        {
            i++;
            ord++;
        }
        if(ord == 0) sol++;
    }
    fout << sol;
}

int main()
{
    read();
    return 0;
}