C
B
A
C
C
C
C
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
___________
i
ihate
h
a
t
e
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
_
_
_
_
_
_
_
_
_
_
_
_
head
tail
0
5
24
58
34
41
78
67
62
69
64
45
1
2
3
Stack
text editor
A
B
A
A
C
A
D
C
A
C
A
Implementation
_
_
_
_
_
_
_
_
_
_
_
_
ptr
_
_
_
_
_
_
_
_
_
_
_
A
ptr
_
_
_
_
_
_
_
_
_
_
P
A
ptr
_
_
_
_
_
_
_
_
_
C
P
A
ptr
_
_
_
_
_
_
_
_
S
C
P
A
ptr
_
_
_
_
_
_
_
_
_
C
P
A
ptr
_
_
_
_
_
_
_
_
_
_
P
A
ptr
_
_
_
_
_
_
_
_
_
O
P
A
ptr
_
_
_
_
_
_
_
_
I
O
P
A
ptr
Queue
printer queue
A
A
B
B
C
C
D
C
D
E
D
E
Implementation
_
_
_
_
_
_
_
_
_
_
_
_
head
tail
_
_
_
_
_
_
_
_
_
_
_
A
head
tail
_
_
_
_
_
_
_
_
_
_
P
A
head
tail
_
_
_
_
_
_
_
_
_
C
P
A
head
tail
_
_
_
_
_
_
_
_
_
C
P
_
head
tail
_
_
_
_
_
_
_
_
S
C
P
_
head
tail
_
_
_
_
_
_
_
I
S
C
P
_
head
tail
_
_
_
_
_
_
E
I
S
C
P
_
head
tail
_
_
_
_
_
_
E
I
S
C
_
_
head
tail
circular buffer
_
A
_
_
_
_
_
_
_
_
_
_
head
tail
B
A
_
_
_
_
_
_
_
_
_
_
head
tail
B
A
_
_
_
_
_
_
_
_
_
C
head
tail
B
_
_
_
_
_
_
_
_
_
_
C
head
tail
_
_
_
_
_
_
_
_
_
_
_
C
head
tail
Deque
A
P
C
S
Implementation
_
_
_
_
_
_
_
_
_
_
_
_
head
tail
_
_
_
_
_
_
_
_
_
_
_
P
head
tail
_
_
_
_
_
_
_
_
_
_
C
P
head
tail
_
_
_
_
_
_
_
_
_
S
C
P
head
tail
A
_
_
_
_
_
_
_
_
S
C
P
head
tail
A
_
_
_
_
_
_
_
_
_
C
P
head
tail
A
_
_
_
_
_
_
_
_
_
_
P
head
tail
A
G
_
_
_
_
_
_
_
_
_
P
head
tail
Linked List
prev
next
data
prev
next
data
prev
next
data
prev
next
data
prev
next
data
NULL
NULL
Node
Node
Node
Node
Node
L
K
J
I
H
G
F
E
D
C
B
A
L
K
J
I
H
G
F
E
_
C
B
A
L
K
J
_
H
G
F
E
_
C
B
A
L
K
J
_
_
G
F
E
_
C
B
A
L
K
J
_
_
G
F
E
_
C
B
A
X
Implementation
A
next
prev
B
next
prev
C
next
prev
D
next
prev
D
next
prev
NULL
NULL
delete
A
next
prev
B
next
prev
C
next
prev
A
next
prev
B
next
prev
C
next
prev
insert
A
next
prev
C
next
prev
A
next
prev
B
next
prev
C
next
prev
Tree
indexing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
treap
50,3
23,5
80,11
4,58
37,13
71,47
92,25
9,69
68,90
87,79
99,39
segment tree
[0,6)
[0,3)
[3,6)
[0,1)
[1,3)
[3,4)
[4,6)
[1,2)
[2,3)
[4,5)
[5,6)
Heap
1
min
1
7
min
4
1
7
min
4
1
7
5
min
4
5
7
min
5
7
min
8
5
7
min
Implementation
0
5
24
58
34
41
78
67
62
69
64
45
insert
0
5
24
58
34
41
78
67
62
69
64
45
0
5
24
58
34
41
78
67
62
69
64
45
17
0
5
24
58
34
17
78
67
62
69
64
45
41
0
5
17
58
34
24
78
67
62
69
64
45
41
delete
0
5
24
58
34
41
78
67
62
69
64
45
5
24
58
34
41
78
67
62
69
64
45
5
24
58
34
41
78
67
62
69
64
45
45
24
58
34
41
78
67
62
69
64
5
34
24
58
45
41
78
67
62
69
64
5
arange
2x+1
2x
x
index
value
arange(x)
\(\min(a, b, c)=\)
\(b\)
\(c\)
\(a\)
2x+1
2x
x
return x
return 2x
return 2x+1
回傳 \(a\) 的新位置
BST
B
A
C
A
B
C
<
<
C
A
B
C
<
<
A
B
insert
41
34
62
0
45
78
5
58
69
99
41
34
62
0
45
78
5
58
69
99
< 43
41
34
62
0
45
78
5
58
69
99
43 <
41
34
62
0
45
78
5
58
69
99
43 <
41
34
62
0
45
78
5
58
69
99
43
find
41
34
62
0
45
78
5
58
69
99
43
< 69
41
34
62
0
45
78
5
58
69
99
43
< 69
41
34
62
0
45
78
5
58
69
99
43
69 <
41
34
62
0
45
78
5
58
69
99
43
found
Dsu
boss
boss
boss
boss
chief
chief
boss
chief
chief
chief
A
B
set A
set B
A
B
set A+B
APCSCamp - Data Structures
By thomaswang2003
APCSCamp - Data Structures
- 273