Cod sursa(job #3249133)
| Utilizator | Data | 14 octombrie 2024 21:04:14 | |
|---|---|---|---|
| Problema | Schi | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <stdio.h>
const int NMAX = 3000, NIL = 0;
int next[NMAX + 1];
int main() {
FILE *fin, *fout;
int n, i, j, a, p, lp;
fin = fopen("schi.in", "r");
fscanf(fin, "%d", &n);
for (i = 1; i <= n; i++) {
fscanf(fin, "%d", &a);
p = next[NIL];
lp = NIL;
for (j = 0; j < a - 1; j++) {
lp = p;
p = next[p];
}
next[i] = next[lp];
next[lp] = i;
}
fclose(fin);
fout = fopen("schi.out", "w");
p = next[NIL];
while (p != NIL) {
fprintf(fout, "%d\n", p);
p = next[p];
}
fclose(fout);
return 0;
}
