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

做气球装饰可以上哪些网站长沙的互联网网站公司哪家好

做气球装饰可以上哪些网站,长沙的互联网网站公司哪家好,史上最全的微信小程序代码大全,建设网站准备资料打LCT的时候发现Splay很不熟, 因此这里贴一下模板 洛谷P3369 https://www.luogu.org/problem/show?pid3369#sub /* 提一些要注意的点: 1. 注意判断边界, 不要访问到空节点 2. 每一次操作或访问完以后, 记得要splay到root 3. insert操作只要update当前节点和父亲节点即可, 因为… 打LCT的时候发现Splay很不熟, 因此这里贴一下模板 洛谷P3369 https://www.luogu.org/problem/show?pid3369#sub /* 提一些要注意的点: 1. 注意判断边界, 不要访问到空节点 2. 每一次操作或访问完以后, 记得要splay到root 3. insert操作只要update当前节点和父亲节点即可, 因为还会上旋到root 4.牢记双旋的打法 5. delete时需要把将要delete的点上旋的根, 因此可与find共用函数 6. 在找一个bst中原本不存在的点的前驱或后继时, 可先将该点插入, 然后找前驱或后继, 然后再删除 */ #includecstdio #includecctype #includecstring using namespace std; void read(int x) {x 0;char c;int flag 1;while(! isgraph(c getchar()))if(c -)flag * - 1;while(isgraph(c))x x * 10 c - 0, c getchar();x * flag; } const int MAXN (int)1e5; int top; struct node {int key, cnt, ch[2], size, fa; }T[MAXN 64]; int root; void create(int x) {T[top].ch[0] T[top].ch[1] - 1;T[top].key x;T[top].cnt 1;T[top ].size 1; } void update(int u) {T[u].size T[u].cnt;if(T[u].ch[0] ! - 1)T[u].size T[T[u].ch[0]].size;if(T[u].ch[1] ! - 1)T[u].size T[T[u].ch[1]].size; } inline int getson(int p) {return (p T[T[p].fa].ch[1]); } void rotate(int p) {int fa T[p].fa, fafa T[fa].fa, k getson(p);T[fa].ch[k] T[p].ch[k ^ 1];T[T[p].ch[k ^ 1]].fa T[p].fa;T[p].ch[k ^ 1] fa;T[fa].fa p;T[p].fa fafa;if(fafa ! - 1)T[fafa].ch[T[fafa].ch[1] fa] p;update(fa), update(p); } void splay(int u) {for(int fa; (fa T[u].fa) ! - 1; rotate(u))if(T[fa].fa ! - 1)rotate((getson(u) getson(fa)) ? fa : u);root u; } void insert(int x) {if(root ! - 1){int p root, fa - 1;while(1){if(T[p].key x){T[p].cnt ;update(p), update(fa);//这里只需要更新p和fa就可以了 splay(p);//因为这里还会更新到p到根节点上的所有祖先 break;}fa p;p T[p].ch[x T[fa].key];if(p - 1){create(x);T[top - 1].fa fa;T[fa].ch[x T[fa].key] top - 1;update(fa);splay(top - 1);break;}}}elsecreate(x), T[top - 1].fa root, root top - 1; } int find(int x) //写得有点奇怪了, 因为强行把两个操作合并在一起233 {int p root, sum 0;while(1){if(x T[p].key)p T[p].ch[0];else{sum (T[p].ch[0] - 1) ? 0 : T[T[p].ch[0]].size;if(x T[p].key){splay(p);return sum 1;}sum T[p].cnt;p T[p].ch[1];}} } int get_pre() {int p T[root].ch[0];while(T[p].ch[1] ! - 1)p T[p].ch[1];return p; } void del(int x) //下面就是无聊的分类讨论了 {find(x);if(T[root].cnt 1){T[root].cnt --;update(root);return;}if(T[root].ch[0] - 1 T[root].ch[1] - 1){root - 1;return;}if(T[root].ch[1] - 1){int tmp root;root T[root].ch[0];T[root].fa - 1;return;}elseif(T[root].ch[0] - 1){int tmp root;root T[root].ch[1];T[root].fa - 1;return;}int pre get_pre(), tmp root;splay(pre);T[T[tmp].ch[1]].fa root;T[root].ch[1] T[tmp].ch[1];update(root); } void print(int x) {if(x 0)putchar(-);if(x 0)putchar(0);int ans[10], top 0;while(x)ans[top ] x % 10, x / 10;for(; top; top --)putchar(ans[top - 1] 0); } int get_rank(int x) {int p root;while(1){if(T[p].ch[0] ! - 1 x T[T[p].ch[0]].size)p T[p].ch[0];else{int tmp ((T[p].ch[0] ! - 1) ? T[T[p].ch[0]].size : 0) T[p].cnt;if(x tmp)return T[p].key;x - tmp;p T[p].ch[1]; }} } int get_next() {int p T[root].ch[1];while(T[p].ch[0] ! - 1)p T[p].ch[0];return p; } int main() {#ifndef ONLINE_JUDGEfreopen(L3369.in, r, stdin);freopen(L3369.out, w, stdout);#endifint n;read(n);root - 1;top 0;for(int i 0; i n; i ){int opt, x;read(opt), read(x);switch (opt){case 1: insert(x); break;case 2: del(x); break;case 3: print(find(x)); putchar(\n); break;case 4: print(get_rank(x)); putchar(\n); break;case 5: {insert(x);print(T[get_pre()].key);putchar(\n);del(x);break;}case 6:{insert(x);print(T[get_next()].key);putchar(\n);del(x);break;}}} } 转载于:https://www.cnblogs.com/ZeonfaiHo/p/6402841.html
http://www.zqtcl.cn/news/513708/

相关文章:

  • 做网站怎么注册营业执照民制作网站哪家便宜
  • 临沂做进销存网站推广软件公司
  • 网站前端建设唐山网站建设托管
  • 做效果图有哪些网站seo怎么做关键词排名
  • 深圳手机网站开发什么网站可以做英语题
  • 网站优化什么意思图片展示网站
  • 建德做网站米趋外贸网站建设
  • 国外优秀的设计网站八爪鱼磁力搜索引擎
  • 网站建设优化陕西网络营销推广方法与策略
  • 网站建设推广者怎样找到客户百度seo排名帝搜软件
  • 绵阳网站托管网站建设第一品牌
  • 张家港网站建设培训班电商seo引流
  • 网站安全怎么做手机网站 焦点图
  • 阿里云做网站的代码网上申请入团网站
  • 精品课程网站怎么做建筑图纸符号大全解释
  • 高权重网站 内页做跳转给新网站许昌做网站公司哪家专业
  • 咸阳网站建设工作室网站建设经
  • 网站怎么做短信接口新浪wordpress
  • 方维o2o 2.9蓝色团购网站程序源码模板做一电影网站怎么赚钱
  • 口碑好网站建设资源新昌网站建设
  • 苏州做网站的公司排名泉州网络推广专员
  • 无为县做互联网网站备案的时候网站建设方案书要吗
  • 修改网站的备案主体dede网站地图不显示文章列表
  • 建立个人网站的成本织梦html5手机网站模板
  • 怎么自己建一个网站吗php网页设计培训
  • 深圳大型论坛网站建设wordpress国内加速
  • 仿站怎么做广告装饰公司名字
  • 黄冈网站推广收费标准wordpress导航页面设置密码
  • 做网站会犯法吗贵州省建设厅城乡建设网站
  • 做网站和做公众号资金盘网站怎么建设