当前位置: 首页 > news >正文

咸阳市城乡建设规划局网站网站网页链接

咸阳市城乡建设规划局网站,网站网页链接,大型网站建设公司有哪些,郑州陆港开发建设有限公司网站题目大意#xff1a; 您需要写一种数据结构#xff08;可参考题目标题#xff09;#xff0c;来维护一些数#xff0c;其中需要提供以下操作#xff1a; 1. 插入x数 2. 删除x数(若有多个相同的数#xff0c;因只删除一个) 3. 查询x数的排名(若有多个相同的数#xff0c…题目大意 您需要写一种数据结构可参考题目标题来维护一些数其中需要提供以下操作 1. 插入x数 2. 删除x数(若有多个相同的数因只删除一个) 3. 查询x数的排名(若有多个相同的数因输出最小的排名) 4. 查询排名为x的数 5. 求x的前驱(前驱定义为小于x且最大的数) 6. 求x的后继(后继定义为大于x且最小的数) 思路 直接splay 今天才敲。。。 1 #includeiostream2 #includecstdio3 #includecmath4 #includecstdlib5 #includecstring6 #includealgorithm7 #includevector8 #includequeue9 #define inf 213906214310 #define ll long long11 #define MAXN 100100 12 #define MOD 100000000713 using namespace std;14 inline int read()15 {16 int x0,f1;char chgetchar();17 while(!isdigit(ch)) {if(ch-) f-1;chgetchar();}18 while(isdigit(ch)) {xx*10ch-0;chgetchar();}19 return x*f;20 }21 int ch[MAXN][2],fa[MAXN],sz,cnt[MAXN],val[MAXN],size[MAXN],rt;22 int which(int x) {return xch[fa[x]][1];}23 int find_pre()24 {25 int posch[rt][0];26 while(ch[pos][1]) posch[pos][1];27 return pos;28 }29 int find_sub()30 {31 int posch[rt][1];32 while(ch[pos][0]) posch[pos][0];33 return pos;34 }35 void upd(int x)36 {37 if(!x) return ;38 size[x]cnt[x]size[ch[x][1]]size[ch[x][0]];39 }40 void rotate(int pos)41 {42 int ffa[pos],fffa[f],kwhich(pos);43 ch[f][k]ch[pos][k^1],fa[ch[f][k]]f,fa[f]pos,ch[pos][k^1]f,fa[pos]ff;44 if(ff) ch[ff][ch[ff][1]f]pos;45 upd(f);upd(pos);46 }47 void splay(int x)48 {49 for(int f;ffa[x];rotate(x))50 if(fa[f]) rotate((which(x)which(f)?f:x));51 rtx;52 }53 void Insert(int x)54 {55 int posrt,f0;56 while(1)57 {58 if(val[pos]x) {cnt[pos],upd(pos);upd(f);splay(pos);return ;}59 fpos,posch[pos][xval[pos]];60 if(!pos)61 {62 ch[sz][0]ch[sz][1]0,fa[sz]f,val[sz]x,cnt[sz]size[sz]1,ch[f][xval[f]]sz;63 upd(f);splay(sz);return ;64 }65 }66 }67 void insert(int x)68 {69 if(!rt) {val[sz]x,ch[sz][0]ch[sz][1]fa[sz]0,cnt[sz]size[sz]1,rtsz;return;}70 Insert(x);71 }72 int find_rank(int x)73 {74 int res0,posrt;75 while(1)76 {77 if(xval[pos]) posch[pos][0];78 else79 {80 ressize[ch[pos][0]];81 if(val[pos]x) {splay(pos);return res1;}82 rescnt[pos],posch[pos][1];83 }84 }85 }86 int find_num(int x)87 {88 int tmp0,posrt;89 while(1)90 {91 if(ch[pos][0]xsize[ch[pos][0]]) posch[pos][0];92 else93 {94 tmpsize[ch[pos][0]]cnt[pos];95 if(xtmp) return val[pos];96 x-tmp,posch[pos][1];97 }98 }99 } 100 void dlt(int x) 101 { 102 find_rank(x); 103 if(cnt[rt]1) {cnt[rt]--;return ;} 104 if(!ch[rt][0]!ch[rt][1]) {rt0;return ;} 105 if(!ch[rt][0]||!ch[rt][1]) 106 { 107 int k!ch[rt][1]?0:1; 108 rtch[rt][k],fa[rt]0; 109 return ; 110 } 111 int kfind_pre(),tmprt; 112 splay(k);fa[ch[tmp][1]]rt; 113 ch[rt][1]ch[tmp][1],rtk; 114 } 115 int main() 116 { 117 int Tread(),opt,x; 118 while(T--) 119 { 120 optread(),xread(); 121 if(opt1) insert(x); 122 if(opt2) dlt(x); 123 if(opt3) printf(%d\n,find_rank(x)); 124 if(opt4) printf(%d\n,find_num(x)); 125 if(opt5) {insert(x);printf(%d\n,val[find_pre()]);dlt(x);} 126 if(opt6) {insert(x);printf(%d\n,val[find_sub()]);dlt(x);} 127 } 128 } View Code  转载于:https://www.cnblogs.com/yyc-jack-0920/p/8047274.html
http://www.huolong8.cn/news/14478/

相关文章:

  • 网络服务网站建设酒店装修
  • 郑州科大医院长沙优化排名
  • 提高企业网站的访问率wordpress ediclot
  • 湛江网站建设公司哪家好自助建站网站建设
  • 精品网站建设费用磐石网络网站优化怎样做外链
  • 烟台建站软件wordpress 变私有云
  • 建设厅培训中心网站企业网站框架
  • 南昌市建设工程质量监督网站网络需求分析
  • wordpress文档主题wordpress固定链接优化
  • 免费注册网站的平台wordpress代码架构
  • 网站导航页面制作网站seo模块
  • 网站策划的具体内容是什么邮箱网页版入口
  • 网站开发工程师介绍扶风做网站
  • 徐州网站设计师兼职做视频的网站
  • 个人博客网站下载做做做网站
  • 企业网站公司单位有哪些商场设计平面图
  • 做网站哪家公司最好深圳网络营销全网推广
  • 怎么用新浪云做淘宝客网站周口seo优化
  • 公司建网站怎么建成都竞价托管多少钱
  • 建筑网结构哪里有做网站优化的公司
  • 江西做网站的公司有哪些自媒体发布软件app
  • 百度网站推广教程中国做的网站国外能打开吗
  • 手机和网站页面模板wordpress 所以文章
  • 唐河网站制作公司公司网站招聘的作用
  • 建站之星网站成品分离文山网站建设报价
  • 龙华做棋牌网站建设注册一家公司最低需要多少钱
  • 丰台网站建设联系方式wordpress章节分页
  • 常州网络公司中环互联网网站建设有什么网站可以做跳转连接的
  • 优秀平面设计网站凡科快图登录入口
  • 个人可以做购物网站吗wordpress目录主题