Cod sursa(job #2633686)

Utilizator betybety bety bety Data 8 iulie 2020 11:28:29
Problema Nums Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.93 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("nums.in");
ofstream out("nums.out");
struct number
{
    string nr;
    bool operator <(number other) const
    {
        if(nr.size()<other.nr.size()) return true;
        if(nr.size()>other.nr.size()) return false;
        return nr<other.nr;
    }
    bool operator >(number other) const
    {
        if(nr.size()<other.nr.size()) return false;
        if(nr.size()>other.nr.size()) return true;
        return nr>other.nr;
    }
    bool operator ==(number other) const
    {
        return nr==other.nr;
    }
};
set<number> s;
int main()
{
    int n,tip,k;
    number aux;
    in>>n;
    while(n--)
    {
        in>>tip;
        if(tip==1)
        {
            in>>aux.nr;
            s.insert(aux);
        }
        else
        {
            in>>k;
            out<<(*(next(s.begin(),k-1))).nr<<'\n';
        }
    }
    return 0;
}