zoukankan      html  css  js  c++  java
  • 【BZOJ3678】Wangxz和OJ

    题意:

    不想讲

    题解:

    Rope真香!

    正解是Splay缩点,访问时再拆成一个序列

    代码:

     1 //STL dafa good!
     2 #include<algorithm>
     3 #include<iostream>
     4 #include<cstring>
     5 #include<cstdio>
     6 #include<cmath>
     7 #include<queue>
     8 #include<ext/rope>
     9 #define inf 2147483647
    10 #define eps 1e-9
    11 using namespace std;
    12 using namespace __gnu_cxx;
    13 typedef long long ll;
    14 rope<short>rp;
    15 short a[20001],s[200001];
    16 int l,r,p,tmp,n,m,op;
    17 int main(){
    18     scanf("%d%d",&n,&m);
    19     for(int i=0;i<n;i++)scanf("%d",&a[i]);
    20     rp=rope<short>(a,a+n);
    21     for(int i=1;i<=m;i++){
    22         scanf("%d",&op);
    23         if(op==0){
    24             scanf("%d%d%d",&p,&l,&r);
    25             tmp=0;
    26             for(int i=l;i<=r;i++)s[tmp++]=i;
    27             rp=rp.substr(0,p)+rope<short>(s,s+r-l+1)+rp.substr(p,rp.size()-p);
    28         }
    29         if(op==1){
    30             scanf("%d%d",&l,&r);
    31             rp=rp.substr(0,l-1)+rp.substr(r,rp.size()-r);
    32         }
    33         if(op==2){
    34             scanf("%d",&p);
    35             printf("%d
    ",rp[p-1]);
    36         }
    37     }
    38     return 0;
    39 }
    40 //zhenshanren
  • 相关阅读:
    视音频开发测试文件下载
    H.264 中的Annex B格式和AVCC格式
    FFmpeg——命令笔记
    Gamma 矫正
    头文件 <string.h> <cstring> <string> 区别
    Serializable
    Oracle学习
    JDBC
    Servlet为主理解cookie,session,filter
    javaweb复习-环境篇
  • 原文地址:https://www.cnblogs.com/dcdcbigbig/p/9630126.html
Copyright © 2011-2022 走看看