破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下.你却不知道此问题,而是专心致志地打稿子,甚至显示器都没开.当你打开显示器之后,展现你面前的数一段悲剧文本.你的任务是在显示器打开前计算出这段悲剧的文本. 给你一段按键的文本,其中'['表示Home键,']'表示End键,输入结束标志是文件结束符(EOF). 样例输入 This_is_a_[Beiju…
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally). You're not aware of this iss…
题目链接:https://vjudge.net/problem/UVA-11988 题目大意:输入一个字符串,输出在原本应该是怎么样的?  具体方法是 碰到' [ ' 回到最前面  碰到‘ ]’  回到最后面. 思路:很容易可以想到用数组来写,但是仔细分析一下,每次你把一个字符插入到最前面,它后面的字符全都要往后移,那么复杂度是多大呢?  最差的情况,每一个都插在最前面,呢么复杂度是 n*n   肯定超时的.  应用链表则只有n的复杂度了.  这是我接触到的第一道链表题目,说的详细一点: 比如 …
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally). You're not aware of this iss…
11988 - 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 problemwith the keyboard is that sometimes the “home” key or the “end” key gets automatically pressed(internally).Yo…
11988 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 withthe keyboard is that sometimes the “home” key or the “end” key gets automatically pressed (internally).You’…
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 with the keyboard is that sometimes the "home" key or the "end" key gets automatically pres…
N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that som…
题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3139 You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problemwith the keyboard is that…
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally). You're not aware of this iss…
问题:You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key or the “end” key gets automatically pressed (internally). You’re not aware of this issue, since yo…
题目传送门 题意:训练指南P244 分析:链表模拟,维护链表的head和tail指针 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct Link_list { char ch; Link_list *nex; }link_list[N]; int main(void) { while (true) { Link_list *head = link_list; Link_list *q = li…
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链表存储顺序. pos表示光标位置 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> using namespace st…
题意: 模拟一个文本编辑器,可以输入字母数字下划线,如果遇到'['则认为是Home键,如果是']'则认作End键. 问最终屏幕上显示的结果是什么字符串. 分析: 如果在数组用大量的移动字符必然很耗时.所以next数组表示显示屏中s[i]右边的字符编号,变量cur模拟光标,即当前光标位于s[cur]的右边. 变量last记录显示屏最后一个字符的下标. 我理解的连接的情况应该是这样子的: //#define LOCAL #include <cstdio> #include <cstring&…
一开始不懂啊,什么Home键,什么End键,还以为相当于括号,[]里的东西先打印出来呢.后来果断百度了一下. 悲催啊... 题意:给定一个字符串,内部含有'['和']'光标转移指令,'['代表光标移向文章头,']'代表光标移向文章尾,问最终在屏幕上显示的字符串序列是什么 思路:直接模拟一下即可,不过因为由于会可能移动到字符串开头以及结尾,所以我开了3个char数组. str1存储由于'['的原因而打印在开头的字符,str3存储由于']'的原因打印在结尾的字符,str2则是存储一开始在没遇到'['…
刘汝佳的题目,悲剧文本 -_-||| 这里使用vector<string>容器倒置记录数据,然后从后面输出就能够了. 难度就是不知道这种文档究竟哪里是開始输出,故此使用动态管理内存的容器比較好做. 添加了io处理的O(n)算法也没有上榜,郁闷. #include <stdio.h> #include <vector> #include <string> using std::vector; using std::string; const int MAX_B…
题目描述: 题目思路: 1.使用链表来重新定位各个字符 2.用数组实现链表 3.开一个数组list[i]来存储字符数组下一个字符的位置 #include <iostream> #include <cstring> using namespace std; + ; int last,cur,list[maxn] ; char s[maxn] ; int main(int argc, char *argv[]) { ) == ) { ); last = cur = ; list[] =…
使用list来模拟就行了,如果熟悉list,那么这道题真是分分钟秒掉... list是双向循环链表,插入和删除操作非常快,缺点是不能像数组一样随机按下标读取. 一下是wiki上说明的相关函数:http://zh.wikipedia.org/wiki/List_(STL) Iterators: list.begin() 回传指向第一个元素的 Iterator. list.end() 回传指向最末元素的下一个位置的 Iterator. list.rbegin() 回传指向最末个元素的反向 Itera…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 会链表的插入操作的话.这个就不难了. 放置两个哨兵节点. 然后模拟插入一个节点的过程就好. 实时修改光标就好->即下一个插入的位置. [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e5; const int fir = 0, last = N + 10; int nex[N + 100],len,be; char s[N + 100];…
题目大意:将一个字符串改变顺序后输出.遇到“[”就将后面内容拿到最前面输出,遇到“]”就将后面的内容拿到最后面输出. 题目分析:用nxt[i]数组表示i后面的字符的下标,实际上就是以字符i为头建立链表,写法类似链式前向星. 代码如下: # include<iostream> # include<cstdio> # include<cstring> # include<algorithm> using namespace std; char p[100005]…
参考:https://blog.csdn.net/lianai911/article/details/41831645 #include <iostream> #include <cstdio> #include <cstring> #include <vector> using namespace std; ;//若在函数内开过大数组,会显示Process returned -1073741571 (0xC00000FD)错误! string s; vec…
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链表存储顺序. pos表示光标位置 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> using namespace st…
题目链接:https://www.luogu.org/problemnew/show/UVA11988 这题虽说是和链表有关的模拟,但其实并不是很需要啊,但蒟蒻用了(说的好听是练手,说的难听是太弱),效果海星. 分析: 此题模拟即可,本人估计难度大概提高-,可以直接数组模拟,也可以用链表存储.主要是每组数据有多组输入,所以读入的方法可以多加注意,我的这种方法海星(这么有自信是因为是跟大佬学的),然后灵魂活运用for语言即可. 其他在代码中说明. 代码: #include<iostream> #…
即将dfs()放到打印本段字符的后面 不过汝佳书上面说是用链表写的,无意中用递归写出来了,而且写的挺简单的,代码不复杂,写这个博客主要是想记住递归这种神奇的方法 平时递归搜索时候,dfs()的在其他代码的前后不同会有不同的效果,还有就是在递归前标记某一个,递归后消除这个标记(最经典的是暴力枚举排序) 在递归中也会经常遇到边递归边打印或者是全部递归之后再打印,这些各有不同 而这道题目就充分利用这个特点:递归强行的将一个代码片段或一个操作的执行顺序改变 这个题目其实不难,大概意思就是按了一个[ 就在…
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end 两个键, 我们知道如果录入home则将光标定位到字符首,如果录入end则是将光标定位到字符尾.现 在让你输出这段坏了文本. 表示:home => '[' , end => ']' 举例: input: hello[_Tom_]! output: _Tom_hello! 解题思路: 数组中频繁移动元…
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int main() { while(scanf("%s",str)!=EOF) { deque<int > q; int i=0; while(str[i]=='['||str[i]==']') i++; q.push_front(i); while(str[i]) { if(str[…
这题我是大写的服气,辛辛苦苦搞了个双重链表结果还一直不对,不对就算了,书上源代码打进去还是不对,我能怎么办我也很无奈.不过这题还是让我对双重链表更加了解和运用了!还是可以的! You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key or the “end”…
题目描写叙述 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen. Now given a string that you are supposed to type, and the string that you actually type…
time limit per test2 secondsmemory limit per test256 megabytesinput: standard inputoutput: standard output Recently, Norge found a string s=s1s2…sn consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to typ…
链接: https://codeforces.com/contest/1272/problem/C 题意: Recently, Norge found a string s=s1s2-sn consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string s. Yes, all n(n+1)2 of…