forked from shunr/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcco10p3.cpp
More file actions
42 lines (38 loc) · 878 Bytes
/
cco10p3.cpp
File metadata and controls
42 lines (38 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define at find_by_order
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int, null_type,
greater<int>,
rb_tree_tag,
tree_order_statistics_node_update> bst;
int ratingof[1000001];
unordered_map<int, int> idof;
int main() {
bst tree;
int n, a, b;
char q;
scanf("%i", &n);
for (int i = 0; i < n; i++) {
scanf(" %c", &q);
if (q == 'N') {
scanf("%i %i", &a, &b);
tree.insert(b);
ratingof[a] = b;
idof[b] = a;
} else if (q=='M') {
scanf("%i %i", &a, &b);
tree.erase(ratingof[a]);
tree.insert(b);
ratingof[a] = b;
idof[b] = a;
} else {
scanf("%i", &a);
printf("%i\n", idof[*tree.at(a-1)]);
}
}
}