Cod sursa(job #2909926)

Utilizator vlad2009Vlad Tutunaru vlad2009 Data 16 iunie 2022 21:51:27
Problema Nums Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <fstream>
#include <set>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

oset<pair<int, string>> s;

int main() {
    ifstream fin("nums.in");
    ofstream fout("nums.out");
    int q;
    fin >> q;
    while (q--) {
        int t;
        fin >> t;
        if (t == 0) {
            int p;
            fin >> p;
            fout << ((s.find_by_order(p - 1))->second) << "\n";
        } else {
            string k;
            fin >> k;
            s.insert({k.size(), k});
        }
    }
    return 0;
}