Cod sursa(job #558596)

Utilizator cont_de_testeCont Teste cont_de_teste Data 17 martie 2011 12:58:56
Problema Schi Scor 75
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.99 kb
# include <cstring>
# include <cstdio>
# define verf ++poz == hg ? fread ( ch, 1, hg, stdin ), poz = 0 : 0
using namespace std;
const int hg = 1 << 13;
int poz ;
char ch[ hg ] ;

inline void cit ( int &x ) {
    if ( ch[0] == '\0' ) fread ( ch, 1, hg, stdin ) ;
    else for ( ; ch[poz] < '0' || ch[poz] > '9' ; verf ) ;
    for ( x = 0 ; ch[poz] >= '0' && ch[poz] <= '9' ; x = x * 10 + ch[poz] - '0', verf ) ;
}
int n, i, j, a[30005], b[30005];
int main() {
    freopen("schi.in","r",stdin);
    freopen("schi.out","w",stdout);

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

    for (i = 1; i <= n; i++)
        if (a[i] == i) b[a[i]] = i;
        else {
            //for (i=H[0];i;i--) H[i+Count]=H[i];
            memmove(&b[a[i] + 1],&b[a[i]],sizeof(int)*(i-a[i]));
            /*for (j = i - 1; j >= a[i]; j--)
                b[j + 1] = b[j];*/
            b[a[i]] = i;
        }

    for (i = 1; i <= n; i++)
        printf("%d\n",b[i]);

    return 0;
}