例题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;
}
//
转载于:https://www.cnblogs.com/Wade-/p/5748588.html
例题6-4 Broken Keyboard UVa11988相关推荐
- 例题6-4 破损的键盘(又名:悲剧文本)(Broken Keyboard(a.k.a. Beiju Text), UVa 11988)
例题6-4 破损的键盘(又名:悲剧文本)(Broken Keyboard(a.k.a. Beiju Text), UVa 11988) 链表的应用 #include<iostream> # ...
- UVA11988 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 problemwit ...
- 【刘汝佳代码详解】例题6-4破损的键盘(Broken Keyboard,UVa 11988)
立志用最少的代码做最高效的表达 You're typing a long text with a broken keyboard. Well it's not so badly broken. The ...
- PAT甲级1084 Broken Keyboard:[C++题解]字符串处理、双指针算法
文章目录 题目分析 题目来源 题目分析 来源:acwing ac代码1:双指针算法 读入两个字符串a和b,用两个指针i和j分别遍历a.b.如果a[i] ==b[j],说明键盘没坏,j往后移动一个:如果 ...
- PAT Broken Keyboard (20)
题目描写叙述 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the cha ...
- Broken Keyboard (a.k.a. Beiju Text)
原题及翻译 Broken Keyboard (a.k.a. Beiju Text) 破碎的键盘(a.k.a. Beiju Text) You're typing a long text with a ...
- 【简便解法】1084 Broken Keyboard (20 分)_16行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 On a broken keyboard, some of the keys are worn out. So when you ...
- 1084. Broken Keyboard (20)
题目例如以下: On a broken keyboard, some of the keys are worn out. So when you type some sentences, the ch ...
- Yet Another Broken Keyboard
Recently, Norge found a string s=s1s2-sns=s1s2-sn consisting of nn lowercase Latin letters. As an ex ...
最新文章
- 远程桌面的分辨率最大不会超过本机真实物理机的分辨率
- 50年前就已讨论的数据中心隐私问题
- github 创建新项目
- Android 美团Robust热更新 使用入门
- 另一个绑定事件的方式 为元素绑定事件的区别
- cacheAsBitmap = ‘true' 可以降低cpu,提高效率?
- 批量获取远程计算机MAC
- 执行truffle unbox react报错,出现Error: connect ECONNREFUSED 0.0.0.0:443问题的解决办法
- Hadoop I/O
- 电能计量方案在智能插座产品上的应用之“我见”
- Base64编码原理分析
- c语言fat文件系统,【操作系统】简单FAT文件系统实现
- bzoj1052 覆盖问题 二分答案 dfs
- 【数字IC基础知识1之数字芯片设计流程
- 公钥密码系统主要依赖的三种数学难题:1.大整数因子分解问题 2.离散对数问题 (DLP问题) 3. 椭圆曲线上的离散对数问题(ECDLP)
- 利用Python对文本文件进行简单的处理
- uniapp发布h5
- Xshell登录后自动执行命令
- 一文带你享受数学之优美
- 【文献调研】在Pubmed上搜索特定影响因子期刊上的论文
热门文章
- python重复字符串n次的函数_LeetCode_Python(3)_无重复字符的最长子串
- Springboot 跨域配置
- 十大震撼谷歌地图卫星照
- oracle——expdp与impdp备份使用方法
- 可以打开md_大祥MD型耐磨卧式多级离心泵现货出售中大泵业
- 【自我救赎--牛客网Top101 4天刷题计划】 第一天 热身运动
- 【java学习之路】(javaWeb【后端】篇)005.会话
- 机器人教练走进驾校_机器人教练走进中通驾校
- 网络映射连接不上_Mac连接不上无线网络的解决方法
- Qt总结之一:遍历文件夹和文件目录,并过滤和获取文件信息、后缀名、前缀名(一)