Cod sursa(job #2939656)

Utilizator AztecaVlad Tutunaru 2 Azteca Data 13 noiembrie 2022 23:11:43
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(), move(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;
}