0
点赞
收藏
分享

微信扫一扫

XML HTTP传输 小结

菜菜捞捞 04-13 20:31 阅读 1

Version Controlled IDE

传送门

题面翻译

维护一种数据结构,资磁三种操作。

1.在p位置插入一个字符串s

2.从p位置开始删除长度为c的字符串

3.输出第v个历史版本中从p位置开始的长度为c的字符串

1 ≤ n ≤ 50000 1 \leq n \leq 50000 1n50000,所有字符串总长度小于等于 1 0 6 10^6 106,输出字符串总长度小于等于 20000 20000 20000

强制在线,每次输入中的数字都要减去你的所有输出中字母c的个数

Translated by @litble

题目描述

PDF

输入格式

输出格式

样例 #1

样例输入 #1

6
1 0 abcdefgh
2 4 3
3 1 2 5
3 3 3 4
1 4 xy
3 5 4 6

样例输出 #1

bcdef
bcg
bxyc

注明

以上来自 U V a ,翻译来源:洛谷。 以上来自 UVa,翻译来源:洛谷。 以上来自UVa,翻译来源:洛谷。

不如在洛谷看 UVa 的题,在 vjudge 上交。

易懂版题面来自大佬 @shiyihang。

解题思路

前置知识

正文

需要简化一下题意:

很好的 crope 模版题,直接用 crope 按照题意模拟即可。

AC Code

#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
int n;
char s[1000005];
crope Rope, His[50005];
int Length;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cin >> n;
	int opt, v, p, c, sum = 0;
	crope temp;
	while (n--) {
		cin >> opt;
		if (opt == 1) cin >> p >> s, p -= sum, Rope.insert(p, s), His[++Length] = Rope;
		else if (opt == 2) cin >> p >> c, p -= sum, c -= sum, Rope.erase(p - 1, c), His[++Length] = Rope;
		else cin >> v >> p >> c, v -= sum, p -= sum, c -= sum, temp = His[v].substr(p - 1, c), sum += count(temp.begin(), temp.end(), 'c'), cout << temp << endl;
	}
	return 0;
}

资料来源

举报

相关推荐

0 条评论