Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cctype>
- #include <climits>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <iterator>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- const double EPS = 1e-9;
- const double PI=acos(-1.0);
- #define READ(f) freopen(f, "r", stdin)
- #define WRITE(f) freopen(f, "w", stdout)
- #define INF 999999999999999
- #define pii pair<int, int>
- #define ff first
- #define ss second
- #define ii long long int
- #define uii unsigned long long int
- #define ui unsigned int
- #define MOD 1000000007
- template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); }
- template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); }
- template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); }
- template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;}
- template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
- template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
- //******************DELETE****************
- #ifdef rafiul41
- #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
- #else
- #define debug(args...) // Just strip off all debug tokens
- #endif
- struct debugger{
- template<typename T> debugger& operator , (const T& v){
- cerr<<v<<" ";
- return *this;
- }
- }dbg;
- int bitOn(int N,int pos)
- {
- return N=N | (1<<pos);
- }
- int bitOff(int N,int pos)
- {
- return N=N & ~(1<<pos);
- }
- bool bitCheck(int N,int pos)
- {
- return (bool)(N & (1<<pos));
- }
- ///*******************************************************************************************
- typedef tree<
- int,
- null_type,
- less<int>,
- rb_tree_tag,
- tree_order_statistics_node_update>
- ordered_set;
- ordered_set s;
- int main()
- {
- #ifdef rafiul41
- // READ("in.txt");
- // WRITE("out.txt");
- #endif // rafiul41
- int q;
- scanf("%d",&q);
- s.clear();
- for(int i=0;i<q;i++)
- {
- int x;
- char z[2];
- scanf("%s %d",z,&x);
- if(z[0]=='I')
- {
- s.insert(x);
- }
- else if(z[0]=='C')
- {
- //cout<<s.order_of_key(x)<<endl;
- printf("%d\n",s.order_of_key(x));
- }
- else if(z[0]=='K')
- {
- x--;
- if(s.find_by_order(x)==s.end())
- {
- //cout<<"invalid"<<endl;
- printf("invalid\n");
- }
- else
- {
- printf("%d\n",*s.find_by_order(x));
- //cout<<*s.find_by_order(x)<<endl;
- }
- }
- else
- {
- s.erase(x);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement