Cod sursa(job #1669154)

Utilizator assa98Andrei Stanciu assa98 Data 30 martie 2016 13:54:31
Problema Nums Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.05 kb
#include <fstream>
#include <algorithm>
#include <vector>
#include <ext/pb_ds/detail/standard_policies.hpp>
#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;

struct cmp {
    inline bool operator () (const string &a, const string &b) const {
        if(a.size() != b.size()) {
            return a.size() < b.size();
        }
        return a < b;
    }
};

tree<
string,
null_type,
cmp,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

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

int main() {
    int n;
    fin >> n;
    for(int i = 1; i <= n; i++) {
        int t;
        fin >> t;
        if(t == 1) {
            string s;
            fin >> s;
            ordered_set.insert(s);
        }
        else {
            int k;
            fin >> k;
            fout << *ordered_set.find_by_order(k - 1) << '\n';
        }
/*        for(auto it : ordered_set) {
            fout << it << ' ';
        }
        fout << '\n';*/
    }

    return 0;
}