【平板电视无TLE】非加强能过,加强过不了

P6136 【模板】普通平衡树(数据加强版)

LiuTianyou @ 2022-07-22 16:20:56

这段代码非加强版(P3369)是可以过的,但是加强版把解密用了之后就过不去了

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define I64 "%d"
__gnu_pbds::tree<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> data;
signed main(){
    int n, m, cnt = 0, last = 0, ans = 0;
    scanf(I64 I64, &n, &m);
    for(int i = 1, t; i <= n; i++){
        scanf(I64, &t);
        data.insert(std::make_pair(t, cnt++));
    }
    for(int i = 1; i <= m; i++){
        int op, x;
        scanf(I64 I64, &op, &x);
        x ^= last;
        if(op == 1){
            data.insert(std::make_pair(x, cnt++));
        }else if(op == 2){
            auto it = data.lower_bound(std::make_pair(x, 0));
            data.erase(it);
        }else if(op == 3){
            last = data.order_of_key(std::make_pair(x, 0)) + 1;
        }else if(op == 4){
            last = data.find_by_order(x  - 1)->first;
        }else if(op == 5){
            last = data.find_by_order(data.order_of_key(std::make_pair(x, 0)) - 1)->first;
        }else{
            last = data.find_by_order(data.order_of_key(std::make_pair(x, 2147483647)))->first;
        }
        ans ^= last;
    }
    printf(I64 "\n", ans);
    return 0;
}

两个点AC,8个点WA,无TLE,所以我平板电视如果写对了是可以过的,不用优化,不是时间问题.


by Cat_shao @ 2022-07-22 21:28:11

@Stream_X 那没事了


上一页 |