Cod sursa(job #2782760)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 12 octombrie 2021 22:38:08
Problema Nums Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 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;

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

tree<pair<int, string>, null_type, less<pair<int, string>>, rb_tree_tag, tree_order_statistics_node_update> oset;

void test_case() {
  int n;
  fin >> n;
  for (int i = 1; i <= n; ++i) {
    char op;
    fin >> op;
    if (op == '1') {
      string s;
      fin >> s;
      oset.insert(make_pair(s.size(), s));
    } else {
      int k;
      fin >> k;
      fout << oset.find_by_order(k - 1)->second << '\n';
    }
  }
}

int main() {
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    test_case();
  }
  return 0;
}