zoukankan      html  css  js  c++  java
  • 【luogu P3369 【模板】普通平衡树(Treap/SBT)】 题解 pb_ds

    我永远都爱STL ! 我爱PB_DS !

    #include <iostream>
    #include <cstdio>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/assoc_container.hpp>
    using namespace __gnu_pbds;
    typedef long long ll;
    tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> st;
    int main()
    {
    	int m;
    	ll ans, x, y;
    	scanf("%d",&m);
    	for(int i = 1; i <= m; i++)
    	{
    		scanf("%lld%lld",&x,&y);
    		if(x == 1) st.insert((y<<20)+i);
    		else if(x == 2) st.erase(st.lower_bound(y<<20));
    		else if(x == 3) printf("%d
    ",st.order_of_key(y<<20)+1);
    		else {
    			if(x == 4) ans = *st.find_by_order(y-1);
    			if(x == 5) ans = *--st.lower_bound(y<<20);
    			if(x == 6) ans = *st.lower_bound((y+1)<<20);
    			printf("%lld
    ",ans>>20);
    		}
    	}
    	return 0;
    }
    

    其实还可以用set,vector做...
    我永远都喜欢stl

    隐约雷鸣,阴霾天空,但盼风雨来,能留你在此。

    隐约雷鸣,阴霾天空,即使天无雨,我亦留此地。

  • 相关阅读:
    requireJS搭建
    html启动本地.exe文件
    自定义input[type="checkbox"]的样式
    使用rem单位时css sprites的坑
    visibility API
    css动画
    去除ios端输入框的弹出
    *java类的生命周期
    处理高并发,防止库存超卖
    java注解的使用
  • 原文地址:https://www.cnblogs.com/MisakaAzusa/p/9215543.html
Copyright © 2011-2022 走看看