-
Notifications
You must be signed in to change notification settings - Fork 2
/
HDU-tianjin-1009.cpp
120 lines (104 loc) · 1.52 KB
/
HDU-tianjin-1009.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
ID: mfs6174
email: mfs6174@gmail.com
PROG: ti
LANG: C++
*/
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
#include<set>
#define sf scanf
#define pf printf
#define llg long long
using namespace std;
ifstream inf("ti.in");
//ofstream ouf("ti.out");
//freopen("ti.in","r",stdin);
const int maxlongint=2147483647;
struct D
{
int p[2];
int rx;
int d;
};
int i,j,k,t,n,m,zz,zu,c;
int L,R;
D pp[2100000];
void moveleft(lr)
{
if (lr==1)
L=pp[L].p[1-rx];
else
R=pp[R].p[1-rx];
}
void moveright(lr)
{
if (lr==1)
L=pp[L].p[rx];
else
R=pp[R].p[rx];
}
void insl(int x)
{
c++;
pp[cc].d=x;
int t=pp[L].p[1-rx];
pp[t].p[rx]=cc;
pp[L].p[1-rx]=cc;
pp[cc].p[rx]=L;
pp[cc].p[1-rx]=pp[L].p[1-rx];
}
void insr(int x)
{
c++;
pp[cc].d=x;
int t=pp[R].p[rx];
pp[t].p[1-rx]=cc;
pp[R].p[rx]=cc;
pp[cc].p[1-rx]=R;
pp[cc].p[rx]=pp[R].p[rx];
}
void dell()
{
int t=PP[L].p[1-rx],tt=PP[L].p[rx];
pp[t].p[rx]=tt;
p[tt].p[1-rx]=t;
}
void delr()
{
int t=PP[R].p[1-rx],tt=PP[R].p[rx];
pp[t].p[rx]=tt;
p[tt].p[1-rx]=t;
}
void rvs()
{
}
int main()
{
sf("%d",&zu);
for (zz=1;zz<=zu;zz++)
{
c=0;
sf("%d",&n);
for (i=1;i<=n;i++)
{
sf("%d",&t);
c++;
PP[c].d=t;
pp[c].p[0]=c+1;
pp[c].p[1]=c-1;
pp[c].rx=0;
}
pp[0].d=maxlongint;
pp[c+1].d=maxlongint;
sf("%d%d",&L,&R);