Cod sursa(job #775879)

Utilizator costyrazvyTudor Costin Razvan costyrazvy Data 9 august 2012 11:33:29
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;
vector <int> h[10] ;
long long a[500001],i,mx,y,p,j,n;
int main()
{
    ifstream f("algsort.in");
    ofstream g("algsort.out");
    f>>n;
    for (i=1;i<=n;i++) f>>a[i];
    while (y<=1000000001) {
      for (i=0;i<10;i++) h[i].clear();
     for (i=1;i<=n;i++)
            h[(a[i]/y%10)%666013].pb(a[i]);
     y*=10;
     n=0;
     for (i=0;i<10; i++)
        for(j=0; j<h[i].size();j++)
          a[++n]= h[i][j];
    }

    for (i=1; i<=n; i++) g<<a[i]<<" ";
    f.close();
    g.close();
    return 0;
}