Cod sursa(job #2783815)

Utilizator MateiAruxandeiMateiStefan MateiAruxandei Data 15 octombrie 2021 09:29:12
Problema Nums Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

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

tree < pair<int, string> ,  null_type,  less<pair<int, string> >,  rb_tree_tag,  tree_order_statistics_node_update > ARB;

int main()
{
    int n;
    fin >> n;

    for(int i = 1; i <= n; ++i)
    {
        int t;
        fin >> t;
        if(t == 1)
        {
            string val;
            fin >> val;
            ARB.insert(make_pair(val.size(), val));
        }
        else {
            int val;
            fin >> val;
            string rez = ARB.find_by_order(val - 1)->second;
            fout << rez << '\n';
        }
    }
    return 0;
}