luogu P3369 普通平衡树
STL 实现

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
// luogu-judger-enable-o2
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int ELAS = 1<<14;
static char buf[ELAS],*p1=buf,*p2=buf;
inline char gc()
{
return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,ELAS,stdin),p1==p2)?EOF:*p1++;
}
inline int read ()
{
register int x = 0; register char c = gc(); register bool m = false;
while ((c < '0' || c > '9') && c ^ '-') c = gc();
if (c == '-') m = true, c = gc();
while (c>='0'&&c<='9') x = (x<<3) + (x<<1) + (c^'0'), c = gc();
return m? -x:x;
}
static void write (int x)
{
if (x > 9) write (x / 10);
putchar (x % 10 + 48);
}
static void writelen (int x) {if(x<0) x=-x, putchar('-');write (x);putchar ('\n');}

vector <int> eli;

signed main ()
{
register int n = read (), x, opt;
while (n --)
{
opt = read (), x = read ();
if (opt == 1) eli.insert(upper_bound(eli.begin(), eli.end(), x), x);
else if (opt == 2) eli.erase(lower_bound(eli.begin(), eli.end(), x));
else if (opt == 3) writelen(lower_bound(eli.begin(), eli.end(), x)-eli.begin()+1);
else if (opt == 4) writelen(eli[x - 1]);
else if (opt == 5) writelen(*--lower_bound(eli.begin(), eli.end(), x));
else if (opt == 6) writelen(*upper_bound(eli.begin(), eli.end(), x));
}
return 0;
}

Comments

Please contact the Administrator directly for emergency.





GitHub release (latest by date including pre-releases) GitHub release (latest by date including pre-releases) GitHub repo size GitHub repo size PictureBed PictureBed

Blog content follows the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License

Copyright 2017-2020 ELLIAS views, viewersLoading... Loading...
MOE ICP 辽ICP备20009666号-1 | MOE ICP MOEICP备20201096号