Cod sursa(job #3348389)

Utilizator Darius1414Dobre Darius Adrian Darius1414 Data 21 martie 2026 12:10:12
Problema Nums Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.87 kb
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
struct Cmp{
    bool operator () (const string& a,const string& b) const
        {
            if (a.length()==b.length())
                return a<b;
            return a.length()<b.length();
        }
};
typedef tree<
string,
null_type,
Cmp, // Folosim comparatorul nostru
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

ordered_set mys;
int n,c,x;
string s;
int main()
{
    ifstream f ("nums.in");
    ofstream g ("nums.out");
    f>>n;
    for (int i=1;i<=n;i++)
    {
        f>>c;
        if (c==1)
        {
            f>>s;
            mys.insert(s);
        }
        else
        {
            f>>x;
            g<<*mys.find_by_order(x-1)<<'\n';
        }
    }
}