Cod sursa(job #2945466)

Utilizator Luca07Nicolae Luca Luca07 Data 23 noiembrie 2022 19:44:45
Problema Schi Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.29 kb
//#include <iostream>
#include <fstream>
#include<vector>
using namespace std;

ifstream cin("schi.in");
ofstream cout("schi.out");

vector<int> st;
int n;

void update(int node, int from, int to, int& pos, int& val) {
    if (pos >n)
        return;
    if (from == to) {
        int aux = st[node];
        st[node] = val;
        val = aux;
        pos++;
        return;
    }

    int m = (from + to) / 2;

    if (pos <= m) {
        update(node * 2, from, m, pos, val);
    }
    if(pos>m) {
        update(node * 2 + 1, m + 1, to, pos, val);
    }
}

int query(int node, int from, int to, int ql, int qr) {
    if (from == to) {
        return st[node];
    }

    int m = (from + to) / 2;

    if (ql<=m) {
        return query(node * 2, from, m, ql, qr);
    }
    if (m + 1 <= qr) {
        return query(node * 2 + 1, m + 1, to, ql, qr);
    }
    return 0;

}

vector<int> v;

int main()
{
    int i, nr;

    cin >> n;
    //st.resize(4 * n + 5);
    st.push_back(0);

    for (i = 1; i <= n; i++) {
        cin >> nr;
        st.insert(st.begin()+nr, i);
        int p = i;
        //update(1, 1, n, nr, p);
    }

    for (i = 1; i <= n; i++) {
        cout << st[i] << "\n";//query(1, 1, n, i, i)<<"\n";
    }
    
  

    return 0;
}