题目复制太麻烦了,甩个链接

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693

直接模拟光标操作时间复杂度较高,所以用链表存储顺序。

pos表示光标位置

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char s[];
char ch;
int last,pos;//last存储最后一个字符的位置,pos存储当前光标位置
int nexto[];
int main(){
while(scanf("%s",s+)!=EOF){
int len=strlen(s+);
last=;pos=;
nexto[]=;//初始化
int i;
for(i=;i<=len;i++){
if(s[i]=='[')pos=;
else if(s[i]==']')pos=last;
else{
nexto[i]=nexto[pos];
nexto[pos]=i;
if(pos==last)last=i;//更新最后位置
pos=i;//更新光标位置
}
}
for(i=nexto[];i!=;i=nexto[i])printf("%c",s[i]);
printf("\n");
}
return ;
}

UVa11988 Broken Keyboard (a.k.a. Beiju Text)的更多相关文章

  1. UVA-11988 Broken Keyboard (a.k.a. Beiju Text) (链表 或 递归)

    题目大意:将一个字符串改变顺序后输出.遇到“[”就将后面内容拿到最前面输出,遇到“]”就将后面的内容拿到最后面输出. 题目分析:用nxt[i]数组表示i后面的字符的下标,实际上就是以字符i为头建立链表 ...

  2. UVA11988 Broken Keyboard (a.k.a. Beiju Text)【数组模拟链表】

    参考:https://blog.csdn.net/lianai911/article/details/41831645 #include <iostream> #include <c ...

  3. B - Broken Keyboard (a.k.a. Beiju Text)

    Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...

  4. uva - Broken Keyboard (a.k.a. Beiju Text)(链表)

    11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...

  5. 破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)

    破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. ...

  6. N - Broken Keyboard (a.k.a. Beiju Text)(DFS,链表)

    N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:% ...

  7. UVA——11988 Broken Keyboard (a.k.a. Beiju Text)

    11988 Broken Keyboard (a.k.a. Beiju Text)You’re typing a long text with a broken keyboard. Well it’s ...

  8. Broken Keyboard (a.k.a. Beiju Text) 思路

    问题:You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem ...

  9. B - Broken Keyboard (a.k.a. Beiju Text) 数组模拟链表

    You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem wi ...

随机推荐

  1. C#文件重命名的代码

    C#中没有重命名的方法,自己写了一个方法,来处理文件的重命名. /// <summary> /// 重命名文件夹内的所有子文件夹 /// </summary> /// < ...

  2. Oracle修改表字段类型(number-->varchar2(len)),亲测可用

    思路: --新建临时表以存储正确的顺序create table A_2 as select (column1,colum2,……A表中的顺序) from A_1 ; --删除表A_1drop tabl ...

  3. TensorFlow 常见错误与解决方法——长期不定时更新

    1. TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a builtin_function_or_method ...

  4. 为DEV C++/CodeBlock配置gdb调试遇到的问题

    DEV C++和CodeBlock都只是一个IDE,不能编译调试,需要自己配置MINGW和gdb调试 1.MINGW 在这下载mingw-get-setup.exe安装即可. https://sour ...

  5. apollo命令行传入参数

    Java apollo客户端运行配置 需要在META-INF中创建app.properties文件,以配置app.id 还需要在/opt/settings/server.properties或C:/o ...

  6. sqlserver2012 查询远程数据库

    EXEC sp_addlinkedserver 'LinkName','','SQLOLEDB','121.43.177.236'EXEC sp_addlinkedsrvlogin 'LinkName ...

  7. linux备忘录-例行性工作排程 (crontab)

    例行性工作排程 例行性工作排程分为两类 at at是只执行一次就结束的指令安排.要想使用at,必须要有atd服务的支持. crontab crontab是每隔一段时间自动执行的指令安排.crontab ...

  8. LCA(最近公共祖先)——LCA倍增法

    一.前人种树 博客:最近公共祖先 LCA 倍增法 博客:浅谈倍增法求LCA 二.沙场练兵 题目:POJ 1330 Nearest Common Ancestors 代码: const int MAXN ...

  9. 第十五次ScrumMeeting会议

    第十五次Scrum Meeting 时间:2017/12/5 地点:主201 人员:全体成员 目前工作情况 名字 完成的工作 计划工作 蔡帜 -- -- 游心 完成Scrum会议记录,更新wiki游戏 ...

  10. [译]如何撤销git仓库里的所有修改?

    原文来源:https://stackoverflow.com/questions/29007821/git-checkout-all-the-files 问: 如何撤销我在我git仓库所做的所有修改? ...