[Offer收割]编程练习赛42 register

Ended

Participants:125

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-31 13:08:52

Lang:G++

Edit
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
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
const int MAXN = 100010;
const int INF = 0x7fffffff;
#define lson tr[x].ch[0]
#define rson tr[x].ch[1]
struct Node{
    int ch[2], fa, v, size;
    bool rv;//bool
    void set(int x){v=x; ch[0]=ch[1]=fa=rv=0; size=1;}
}tr[MAXN];
int n, m, root, tot, l, r, x1, x2;
void updata(int x){//size
    if( !x ) return;
    tr[x].size = 1 + tr[lson].size + tr[rson].size;
}
void pushdown(int x){//
    if( !x ) return;
    if( tr[x].rv ){//x
        tr[lson].rv ^= 1; tr[rson].rv ^= 1;//
        tr[x].rv = 0;//
        int t = lson; lson = rson; rson = t;//
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX