zoukankan      html  css  js  c++  java
  • bzoj 1507: [NOI2003]Editor

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<ext/rope>
     4 using namespace std;
     5 using namespace __gnu_cxx;
     6 crope list;
     7 int n,now;
     8 char ch[10],ch1[3000005];
     9 int main()
    10 {
    11     scanf("%d",&n);
    12     for(int i=1;i<=n;i++)
    13       {
    14         int a1;
    15         scanf("%s",ch);
    16         if(ch[0]!='P'&&ch[0]!='N')
    17           scanf("%d",&a1);
    18         if(ch[0]=='M')
    19           now=a1;
    20         if(ch[0]=='I')
    21           {
    22             for(int i=0;i<a1;i++)
    23               {
    24                 ch1[i]=getchar();
    25                 for(;ch1[i]=='
    ';ch1[i]=getchar());
    26               }
    27             ch1[a1]=0;
    28             list.insert(now,ch1);
    29            } 
    30         if(ch[0]=='D')
    31           list.erase(now,a1);
    32         if(ch[0]=='G')
    33           {
    34             list.copy(now,a1,ch1);
    35             ch1[a1]=0;
    36             printf("%s
    ",ch1);
    37           }
    38         if(ch[0]=='P')
    39           now--;
    40         if(ch[0]=='N')
    41           now++;
    42       }
    43     return 0;
    44 }

    本应是个平衡树,偷懒用了list。

  • 相关阅读:
    关于 Vue
    HTTP 知识点
    JS 的一些原生属性
    JS知识点-2 通信类
    原生JS知识点
    CSS知识点
    HTML知识点
    关于在Ajax中使用pushstate
    JavaScript 中的 This
    观察者模式
  • 原文地址:https://www.cnblogs.com/xydddd/p/5271182.html
Copyright © 2011-2022 走看看