UVa11988 Broken Keyboard (a.k.a. Beiju Text)
题目复制太麻烦了,甩个链接
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)的更多相关文章
- UVA-11988 Broken Keyboard (a.k.a. Beiju Text) (链表 或 递归)
题目大意:将一个字符串改变顺序后输出.遇到“[”就将后面内容拿到最前面输出,遇到“]”就将后面的内容拿到最后面输出. 题目分析:用nxt[i]数组表示i后面的字符的下标,实际上就是以字符i为头建立链表 ...
- UVA11988 Broken Keyboard (a.k.a. Beiju Text)【数组模拟链表】
参考:https://blog.csdn.net/lianai911/article/details/41831645 #include <iostream> #include <c ...
- 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 ...
- 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 ...
- 破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)
破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. ...
- 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:% ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- luogu4172 [WC2006]水管局长
就是用 lct 维护最小生成树 ref #include <algorithm> #include <iostream> #include <cstdio> #in ...
- thrift 调取 python php go 客户端代码
golang package main import ( "fmt" "git.apache.org/thrift.git/lib/go/thrift" &qu ...
- nmon Analyser分析仪
nmon Analyser官网: https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power+System ...
- AGV系统上位机--工程案例【1】
1.满足80%系统需求,根据需求生成任务表单 2.指定小车下方任务 3.项目实战应用 4.后台开发,对接其他平台,简易实现自动生成任务列表,自动排单 5.AGV系统上位机初学者很容易理解上手 6.欢迎 ...
- pexpect获取远端命令执行结果
类比于shell的expect, python中使用pexpect模块来模拟用户和终端交互.有的时候使用pexpect.sendline发送命令后,在各种条件影响下, 可能并不能保证命令在远端服务器执 ...
- 扩展欧几里得 求ax+by == n的非负整数解个数
求解形如ax+by == n (a,b已知)的方程的非负整数解个数时,需要用到扩展欧几里得定理,先求出最小的x的值,然后通过处理剩下的区间长度即可得到答案. 放出模板: ll gcd(ll a, ll ...
- web3无法安装的额解决方案-----yarn命令安装web3
凡是可以用 JavaScript 来写的应用,最终都会用 JavaScript 来写. --Atwood定律(Jeff Atwood在2007年提出) yarn命令详解 https://yarnpkg ...
- wampserver 安装后 启动失败的解决方法
安装后启动, 显示 发生未知的异常 wampmanager.exe .... 解决方法 === 其实下载页面说了,先下载 vc的运行库,页面上有链接, 他给的是vc10的,我按照做,失败 查了无数资 ...
- 预处理器&预处理变量&头文件保护&条件编译
[常见的预处理功能] #include 头文件保护符 条件编译 [预处理器] 编译之前执行的一段程序,可以部分地改变我们所写的程序 举个例子:当预处理器看到#include标记时就会用指定的头文件的内 ...
- import方法引入模块详解
在python用import或者from...import或者from...import...as...来导入相应的模块,作用和使用方法与C语言的include头文件类似.其实就是引入某些成熟的函数库 ...