UVAL 6145 Version Controlled IDE
来源:互联网 发布:李圣杰为什么不红 知乎 编辑:程序博客网 时间:2024/05/22 15:31
题意:给三种操作
1.在p位置插入一个字符串.
2.从p位置开始删除长度为c的字符串
3.输出第v个历史版本中从p位置开始的长度为c的字符串
解法:可以用平衡树做,但是不会.后来又听说可一用一个叫rope的神奇的STL,学习了一下,用法基本和string一样.roap的内部是用平衡树实现的,历史版本和当前版本可以共享一些内存,插入和删除整段字符串效率很高.是可持久化的数据结构.
代码如下:
//Time: 952 MS#include <iostream>#include <ext/rope>using namespace std;using namespace __gnu_cxx;crope ro,l[50005],tmp;char str[205];int main(){//freopen("/home/qitaishui/code/in.txt","r",stdin);int n,op,p,c,d,cnt,v;scanf("%d",&n);d = 0;cnt = 1;while(n--){scanf("%d",&op);if(op==1){scanf("%d%s",&p,str);p-=d;ro.insert(p,str);l[cnt++]= ro;}else if(op == 2){scanf("%d%d",&p,&c);p-=d,c-=d;ro.erase(p-1,c);l[cnt++] = ro;}else{scanf("%d%d%d",&v,&p,&c);p-=d,v-=d,c-=d;tmp = l[v].substr(p-1, c);d+=count(tmp.begin(),tmp.end(),'c');cout<<tmp<<"\n";}}}
0 0
- UVAL 6145 Version Controlled IDE
- UVA 12538 Version Controlled IDE
- UVA 12538 Version Controlled IDE 解题报告
- UVA12538 Version Controlled IDE (可持久化Treap)
- 【可持久化平衡树】Version Controlled IDE
- UVA 12538 Version Controlled IDE 可持久化treap
- UVA 12538 Version Controlled IDE(可持久化treap)
- [UVA12538]Version Controlled IDE && 可持久化treap
- uva12538 Version Controlled IDE(可持续化Treap * 模板, STL ext/rope(块状链表))
- UVA 12538 Version Controlled IDE 可持久化平衡树 || rope
- UVAL 7327
- Wing IDE Professional - Version 5.1.12-1
- SAP Web IDE Multi-Cloud Version简介
- uval 5900 二分+枚举
- 优先队列(UVAL-3135)
- UVAL 6267 Beer Pressure
- uval 1752 tree 2
- uval 6425 Intercity
- RapidXML 导致的 crash 问题
- UVAL 6147 Warp Speed II
- Web 端 js 导出csv文件(使用a标签)
- GIT进阶
- 各种距离
- UVAL 6145 Version Controlled IDE
- Tomcat
- Phabricator 实践之安装
- crontab命令
- Java调用bat文件 以及相关dos 命令
- poj-3318(矩阵 随机化)
- java使用cxf webservice
- HOJ 12983 Integer Estate Agent(搜索优化)
- UE4编码规范