Pagini recente » Cod sursa (job #392622) | Cod sursa (job #600619) | Cod sursa (job #3169952) | Cod sursa (job #1582459) | Cod sursa (job #1789457)
#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;
using key_type = pair<int, string>;
using super_tree = tree<key_type, null_type,
less<key_type>, rb_tree_tag, tree_order_statistics_node_update>;
class ipfstream{
ifstream f;
char buf[100000], *p, *ep;
void adv(){
if(++p == ep){
f.read(p=buf, sizeof(buf)); } }
public:
ipfstream(const char * const name): f(name){
f.read(p=buf, sizeof(buf));
ep = buf + sizeof(buf); }
ipfstream& operator>>(char& ch){
for( ; *p == ' ' || *p == '\n'; adv());
ch = *p;
adv();
return *this; }
ipfstream& operator>>(int &x){
for( ; *p == ' ' || *p == '\n'; adv());
for(x = 0; *p != ' ' && *p != '\n'; adv()){
x = 10 * x + *p - '0'; }
return *this; }
ipfstream& operator>>(string& str){
for( ; *p == ' ' || *p == '\n'; adv());
str.erase(begin(str), end(str));
while(true){
char *tmp = p;
while(tmp != ep && *tmp != '\n' && *tmp != ' '){
++tmp; }
str.append(p, tmp-p);
if(tmp != ep){
p = tmp;
break; }
f.read(p=buf, sizeof(buf)); }
return *this; } };
int main(){
ipfstream f("nums.in");
ofstream g("nums.out");
int n, t, x;
string str;
f >> n;
super_tree st;
while(n--){
f >> t;
if(t == 0){
f >> x;
g << st.find_by_order(x-1)->second << '\n'; }
else{
f >> str;
st.insert(make_pair(str.size(), move(str))); } }
return 0; }