forked from Haozh20/dsrw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpa2.cpp
61 lines (60 loc) · 1.21 KB
/
pa2.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
//#define TLX_BTREE_DEBUG
#include"die.cc"
#include"btree_map.h"
using namespace std;
class read{
public:
static const int MAX_SIZE=1<<20;
char buff[MAX_SIZE];
char* buff_end=NULL,*bpos=NULL;
char getc(){
if(buff_end==bpos){
buff_end=buff+fread(buff,1,MAX_SIZE,stdin);
bpos=buff;
}
return *(bpos++);
}
char first_useful(){
char c=getc();
while((c==' ')|(c=='\n')|(c=='\r')){
c=getc();
}
return c;
}
read &operator>>(char &x){
x=first_useful();
return *this;
}
read &operator>>(int &x){
char c = first_useful();
x = 0;
int s=1;
if(c=='-'){
s=-1;
c=getc();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getc();
}
x*=s;
return *this;
}
}IN;
int main(){
tlx::btree_map<int,int> data;
int n;
IN>>n;
for(int i=1;i<=n;++i){
int a,b;
char op;
IN>>op>>a>>b;
if(op=='i'){
data[a]=b;
}
else{
printf("%u\n",data.range_query(a,b));
}
}
}