Pagini recente » Cod sursa (job #1140072) | Cod sursa (job #1754273) | Cod sursa (job #1676208) | Cod sursa (job #3276898) | Cod sursa (job #2783810)
#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");
class cmp
{
public:
bool operator()(string a, string b)
{
if(a.size() == b.size())
return a < b;
return a.size() < b.size();
}
};
tree < string, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update > ARB;
map<string, bool > mp;
int main()
{
int n;
fin >> n;
for(int i = 1; i <= n; ++i)
{
int t;
fin >> t;
if(t == 1)
{
string val;
fin >> val;
if(mp.find(val) == mp.end())
{
ARB.insert(val);
mp[val] = 1;
}
}
else
{
int val;
fin >> val;
string rez = *ARB.find_by_order(val - 1);
fout << rez << '\n';
}
}
return 0;
}