版本比较
初闻满座惊,OP 树科技迎来翻新!
正文
增加 5 行删除 5 行
60 行未改动6162636465666768697071723 行未改动7677787980818283848586878889903 行未改动94959697989910010110212 行未改动60 行未改动class OPTree {private :int fa[N] ,rt[N] ,val[N] ,ls[N] ,rs[N] ; char woc[N] ; bool del[N] ;inline int Find (int x)<% return x == fa[x] ? x : fa[x] = Find (fa[x]) ;%>inline int PreMerge (int x ,int y) {if (!x || !y) return x | y ;if (val[x] > val[y] || (val[x] == val[y] && x > y)) std :: swap (x ,y) ;if (woc[x] == 'O') ls[x] = PreMerge (ls[x] ,y) ;3 行未改动}public :inline void Init (int i)<% return val[rt[i] = fa[i] = i] = ::i[i] ,woc[i] = 'P' ,void () ;%>inline void Merge (int x ,int y) {if (del[x] || del[y]) return ;if ((x = Find (x)) == (y = Find (y))) return ;return fa[y] = x ,rt[x] = PreMerge (rt[x] ,rt[y]) ,void () ;}inline int Delete (int x) {if (del[x]) return -1 ;int ans = val[rt[x = Find (x)]] ;del[rt[x]] = true ,rt[x] = PreMerge (ls[rt[x]] ,rs[rt[x]]) ;3 行未改动int main (void) {std :: ios :: sync_with_stdio (false) ,std :: cin.tie (nullptr) ,std :: cout.tie (nullptr) ;std :: cin >> n >> s ;f (i ,1 ,n ,1) std :: cin >> ::i[i] ,OP.Init (i) ;while (s --> 0) {std :: cin >> G >> e ;12 行未改动60 行未改动6162636465666768697071723 行未改动7677787980818283848586878889903 行未改动94959697989910010110212 行未改动60 行未改动class OPTree {private :int fa[N] ,rt[N] ,val[N] ,ls[N] ,rs[N] ; char woc[N] ; bool del[N] ;inline int Find (int x)<% return x == fa[x] ? x : fa[x] = Find (fa[x]) ;%>inline int PreMerge (int x ,int y) {if (!x || !y) return x | y ;if (val[x] > val[y] || (val[x] == val[y] && x > y)) std :: swap (x ,y) ;if (woc[x] == 'O') ls[x] = PreMerge (ls[x] ,y) ;3 行未改动}public :inline void Init (int i)<% return val[rt[i] = fa[i] = i] = ::i[i] ,woc[i] = 'P' ,void () ;%>inline void Merge (int x ,int y) {if (del[x] || del[y]) return ;if ((x = Find (x)) == (y = Find (y))) return ;return fa[y] = x ,rt[x] = PreMerge (rt[x] ,rt[y]) ,void () ;}inline int Delete (int x) {if (del[x]) return -1 ;int ans = val[rt[x = Find (x)]] ;del[rt[x]] = true ,rt[x] = PreMerge (ls[rt[x]] ,rs[rt[x]]) ;3 行未改动int main (void) {std :: ios :: sync_with_stdio (false) ,std :: cin.tie (nullptr) ,std :: cout.tie (nullptr) ;std :: cin >> n >> s ;f (i ,1 ,n ,1) std :: cin >> ::i[i] ,OP.Init (i) ;while (s --> 0) {std :: cin >> G >> e ;12 行未改动