Cod sursa(job #2175987)

Utilizator DavidLDavid Lauran DavidL Data 16 martie 2018 20:19:41
Problema Nums Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
# include <iostream>
# include <fstream>
# include <string>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
# include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ifstream f("nums.in");
    ofstream g("nums.out");
    tree<pair<int, string>, null_type, less<pair<int, string> >, rb_tree_tag, tree_order_statistics_node_update> v;
    int n,tip,k;
    f>>n;
    for (int i=1;i<=n;i++)
    {
        f>>tip;
        if (tip==1)
        {
            string str;
            f>>str;
            v.insert({str.size(),str});
        } else {
            f>>k;
            g<<v.find_by_order(k-1)->second<< '\n';
        }
    }
    return 0;
}