专栏文章
题解:UVA12538 自带版本控制功能的IDE Version Controlled IDE
UVA12538题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @minuhkiz
- 此快照首次捕获于
- 2025/12/02 08:33 3 个月前
- 此快照最后确认于
- 2025/12/02 08:33 3 个月前
这是一道可癌的水题 rope 题。
前置知识
思路
直接使用 rope 模拟,因为 rope 底层其实是可持久化平衡树,所以可以直接用新版本 旧版本加操作就可以了。
Code
CPP#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
int Q,id,opt,p,v,c,cnt;
rope<char> str[50005],lst,tmp;
string s;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> Q;
while(Q --){
cin >> opt;
if(opt == 1){
cin >> p >> s;
p -= cnt;
lst.insert(p,s.c_str());
str[++id] = lst;
}else if(opt == 2){
cin >> p >> c;
p -= cnt,c -= cnt;
lst.erase(p - 1,c);
str[++id] = lst;
}else{
cin >> v >> p >> c;
v -= cnt,p -= cnt,c -= cnt;
tmp.clear();
tmp = str[v].substr(p - 1,c);
cnt += count(tmp.begin(),tmp.end(),'c');
cout << tmp << '\n';
}
}
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...