日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

bzoj 3224 普通平衡树 vactor的妙用

發(fā)布時(shí)間:2025/5/22 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 bzoj 3224 普通平衡树 vactor的妙用 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

3224: Tyvj 1728 普通平衡樹

Time Limit: 1 Sec??Memory Limit: 256 MB

題目連接

http://www.lydsy.com/JudgeOnline/problem.php?id=3224

Description

您需要寫一種數(shù)據(jù)結(jié)構(gòu)(可參考題目標(biāo)題),來(lái)維護(hù)一些數(shù),其中需要提供以下操作:
1. 插入x數(shù)
2. 刪除x數(shù)(若有多個(gè)相同的數(shù),因只刪除一個(gè))
3. 查詢x數(shù)的排名(若有多個(gè)相同的數(shù),因輸出最小的排名)
4. 查詢排名為x的數(shù)
5. 求x的前驅(qū)(前驅(qū)定義為小于x,且最大的數(shù))
6. 求x的后繼(后繼定義為大于x,且最小的數(shù))

Input

第一行為n,表示操作的個(gè)數(shù),下面n行每行有兩個(gè)數(shù)opt和x,opt表示操作的序號(hào)(1<=opt<=6)

Output

對(duì)于操作3,4,5,6每行輸出一個(gè)數(shù),表示對(duì)應(yīng)答案

Sample Input

10

1 106465

4 1

1 317721

1 460929

1 644985

1 84185

1 89851

6 81968

1 492737

5 493598

Sample Output

106465

84185

492737



HINT

1.n的數(shù)據(jù)范圍:n<=100000

?

2.每個(gè)數(shù)的數(shù)據(jù)范圍:[-1e7,1e7]

題意

?

題解:

用一個(gè)vector來(lái)做

雖然感覺(jué)用set也行

?

代碼:

?

//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200001 #define mod 10007 #define eps 1e-9 int Num; char CH[20]; //const int inf=0x7fffffff; //無(wú)限大 const int inf=0x3f3f3f3f; /*inline void P(int x) {Num=0;if(!x){putchar('0');puts("");return;}while(x>0)CH[++Num]=x%10,x/=10;while(Num)putchar(CH[Num--]+48);puts(""); } */ //************************************************************************************** inline ll read() {int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f; } inline void P(int x) {Num=0;if(!x){putchar('0');puts("");return;}while(x>0)CH[++Num]=x%10,x/=10;while(Num)putchar(CH[Num--]+48);puts(""); }vector<int> q; int main() {int t=read();while(t--){int n=read(),m=read();if(n==1)q.insert(upper_bound(q.begin(),q.end(),m),m);if(n==2)q.erase(lower_bound(q.begin(),q.end(),m));if(n==3)printf("%d\n",lower_bound(q.begin(),q.end(),m)-q.begin()+1);if(n==4)printf("%d\n",q[m-1]);if(n==5)printf("%d\n",*--lower_bound(q.begin(),q.end(),m));if(n==6)printf("%d\n",*upper_bound(q.begin(),q.end(),m));} }

?

轉(zhuǎn)載于:https://www.cnblogs.com/qscqesze/p/4442006.html

總結(jié)

以上是生活随笔為你收集整理的bzoj 3224 普通平衡树 vactor的妙用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。