Pagini recente » Cod sursa (job #2898275) | Cod sursa (job #2471478) | Cod sursa (job #343123) | Cod sursa (job #1159715) | Cod sursa (job #1315752)
#include <fstream>
#include <string>
#include <set>
using namespace std;
ifstream is ("nums.in");
ofstream os ("nums.out");
int N;
struct CMP
{
bool operator ()(const string& a, const string& b)
{
if (a.length() < b.length())
return 1;
else
{
if (a.length() == b.length())
return a < b;
return 0;
}
}
};
set <string, CMP> S;
int main()
{
is >> N;
string x;
for (int i = 1, OP, pos; i <= N; ++i)
{
is >> OP;
if (OP == 1)
{
is >> x;
S.insert(x);
}
else
{
is >> pos;
auto it = S.begin();
advance(it, pos-1);
os << *it << '\n';
}
}
};