题解

6 条题解

  • 0
    @ 2017-05-01 04:36:01
  • 0
    @ 2016-12-28 19:13:07

    STL rope / Splay

    #include <bits/stdc++.h>
    #include <ext/rope>
    inline int read() {
        register int x = 0, f = 1; char ch = getchar();
        while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
        while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ '0'); ch = getchar(); }
        return x * f;
    }
    int main() {
        __gnu_cxx::crope rope;
        int t, now;
        static char ch[3000005];
        t = read();
        char s[10]; int x;
        while (t--) {
            scanf("%s", s);
            switch (s[0]) {
            case 'M': now = read(); break;
            case 'P': now--; break;
            case 'N': now++; break;
            case 'I':
                x = read();
                for (int i = 0; i < x; i++) {
                    ch[i] = getchar();
                    while (ch[i] == '\n')ch[i] = getchar();
                }
                ch[x] = 0;
                rope.insert(now, ch);
                break;
            case 'D': x = read(); rope.erase(now, x); break;
            case 'G': x = read(); rope.copy(now, x, ch); ch[x] = 0; puts(ch);
            }
        }
        return 0;
    }
    
  • 0
    @ 2016-04-12 21:46:23

    cin会tle......

  • 0
    @ 2016-04-12 18:28:54

    ...No cin

  • 0
    @ 2015-02-28 09:16:39

    占沙发

  • 0
    @ 2015-02-28 09:16:28

    沙发

  • 1

信息

ID
1856
难度
8
分类
(无)
标签
递交数
587
已通过
57
通过率
10%
被复制
4
上传者