例题6-4 Broken Keyboard UVa11988
题目分析:
起初这道题目没有做出来,原因是我一直想把整块区域一并插入,而不是逐个插入。今后做题应该注意这个问题,把问题分解去考虑,也许会少走许多弯路。
下边附上AC代码
#include <cstdio>
#include <cstring>
#include <cctype>
char s[100000 + 10];
int next[100000 + 10];
int main(){
while(scanf("%s", s + 1) == 1){
int len=strlen(s+1);
int cur = 0,last=0;
next[0] = 0;
for(int i = 1;i <= len;i++){
if(s[i] =='['){
cur=0;
}
else if(s[i] ==']'){
cur=last;
}
else {
next[i]=next[cur];
next[cur]=i;
if(cur == last)last = i;
cur=i;
}
}
for(int i = next[0];i != 0;i = next[i]){
printf("%c",s[i]);
}
printf("\n");}
return 0;
}
//
例题6-4 Broken Keyboard UVa11988的更多相关文章
- UVa 11998 Broken Keyboard (数组模拟链表问题)
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...
- UVa 11988 Broken Keyboard(链表->数组实现)
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- 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 ...
- PAT1084:Broken Keyboard
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
- PAT 1084 Broken Keyboard
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type ...
- A1084. Broken Keyboard
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- 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 ...
随机推荐
- Centos7升级gcc学习笔记
概述 最近在学习<深入应用C++11-代码与优化与工程级应用>,我的gcc版本是gcc-4.8.5是支持C++11的,但是我在作者的github上看了一些C++例子,其中有些是C++14的 ...
- 1.4.6 其他Schema元素
这里描述了schema.xml中的其他几个重要的元素. 唯一主键-Unique Key uniqueKey元素一篇文档的唯一标记,它几乎总是保证您的应用程序设计,例如,如果你更新索引中的文档,需要用到 ...
- C# 递归程序 获取某个节点下的全部子节点
/// <summary> /// 获取组织结构树 /// </summary> /// <param name="list"></par ...
- Android 4.4 新特性分析-15项大改进!
Google发布了Android 4.4 KitKat,并其同时面世的还有新旗舰Nexus 5.Android 4.4 KitKat有怎样的改进.是否值得升级呢,下面就为大家呈现Android 4.4 ...
- leetcode 题解:Search in Rotated Sorted Array II (旋转已排序数组查找2)
题目: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would t ...
- hg(Mercurial)版本库迁移到git版本库
这几天没事干净搞迁移了,迁移完MVC又迁移版本库,还把工作电脑迁移了一下,开始用Win8.1了.这个迁移主要是因为实在不想在工作电脑上又装git又装hg了,点个右键出来一大堆菜单,况且现在git已经成 ...
- ionic Modal
在ionic中,modal也是添加控制器写服务的~ 在modal.html页面中增加控制器:ng-controller="aboutCtrl"记住要给这个添加控制器.头部使其关闭按 ...
- [python] HDU自动登录提交代码程序
调了一个下午,被python的正则绊住了:在C#上运作好好的式子在python老是报错,原来python的断言式必须是固定长度的,像类似(?<=[^>].*?)的零宽度正回顾后发断言是不允 ...
- python实现发送邮件功能
'''套接字是为特定的网络协议(例如TCP/IP,ICMP/IP,UDP/IP等),允许程序和接受并进行连接,要在python 中建立具有TCP和流套接字的简单服务器,需要使用socket模块,利用该 ...
- codevs4600 [NOI2015]程序自动分析==洛谷P1955 程序自动分析
4600 [NOI2015]程序自动分析 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description 在实现 ...