Broken Keyboard UVA 11988 数组实现链表
这个构造十分巧妙,,,又学到一招,有点类似数组实现的邻接表
#include <iostream>
#include <string.h>
#include <cstdio>
#include <math.h>
#define SIGMA_SIZE 26
#pragma warning ( disable : 4996 ) using namespace std;
typedef long long LL; inline int Max(int a,int b) { return a>b?a:b; }
inline int Min(int a,int b) { return a>b?b:a; }
inline int gcd( int a, int b ) { return b==?a:gcd(b,a%b); }
inline int lcm( int a, int b ) { return a/gcd(a,b)*b; } //a*b = gcd*lcm
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+;
const int maxk = 2e6+; char str[maxn];
int nxt[maxn];
int cur, last; void init()
{
memset( nxt, , sizeof(nxt) );
cur = last = ;
}
int main()
{
while (~scanf("%s", str+))
{
init();
int len = strlen(str+);
nxt[] = ; for ( int i = ; i <= len; i++ )
{
char ch = str[i];
if( ch == '[' ) cur = ;
else if ( ch == ']' ) cur = last;
else {
nxt[i] = nxt[cur];
nxt[cur] = i;
if( cur == last ) last = i;
cur = i;
}
}
for( int i = nxt[]; i; i = nxt[i] )
printf( "%c", str[i] );
printf( "\n" );
}
}
Broken Keyboard UVA 11988 数组实现链表的更多相关文章
- UVa 11988 (数组模拟链表) Broken Keyboard (a.k.a. Beiju Text)
题意: 模拟一个文本编辑器,可以输入字母数字下划线,如果遇到'['则认为是Home键,如果是']'则认作End键. 问最终屏幕上显示的结果是什么字符串. 分析: 如果在数组用大量的移动字符必然很耗时. ...
- Broken Keyboard(模拟数组或者双重链表的运用)
这题我是大写的服气,辛辛苦苦搞了个双重链表结果还一直不对,不对就算了,书上源代码打进去还是不对,我能怎么办我也很无奈.不过这题还是让我对双重链表更加了解和运用了!还是可以的! You’re typin ...
- UVa 11988 Broken Keyboard(链表->数组实现)
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(链表)
题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&pa ...
- UVa 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 wi ...
- UVa 11998 Broken Keyboard (数组模拟链表问题)
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...
- Uva 11988 Broken Keyboard STL+链表
两种方法,直接上代码 STL标准模板库 #include <iostream> #include <list> #include <algorithm> #incl ...
- 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 ...
- 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 ...
随机推荐
- 11_springmvc之RESTful支持
一.理解RESTful RESTful架构,就是一种互联网软件架构.它结构清晰.符合标准.易于理解.扩展方便,所以正得到越来越多网站的采用. RESTful(即Representational Sta ...
- linq to sql any和all的区别
Any说明:用于判断集合中是否有元素满足某一条件:不延迟.(若条件为空,则集合只要不为空就返回True,否则为False).1.简单形式:仅返回没有订单的客户:var q =from c in db. ...
- C# IP正则表达式
public static bool IsValidIp(string strIn) { bool b = Regex.IsMatch(strIn, @"^[0-9]{1,3}\.[0-9] ...
- java 上传MultipartFile和String post请求
/** * POST Multipart Request * @Description: * @param requestUrl 请求url * @param requestText 请求参数 * @ ...
- 满血复活前的记录(持续更新ing)
时隔一年重新开启算法竞赛征程. 该记录大多为老课件.已经做过的习题重做和已经看过的书本重看 7.21 下午到山大 娄晨耀basic_algorithm课件中的内容: 复习线性筛原理 复习差分 做完Co ...
- redis笔记_源码_内存分配
文件:zmoalloc.h zmoalloc.c 1.求两个整数的余数 eg: 求_n对sizeof(long)的余数(_n&(sizeof(long)-1)), 性能提升为50%-100% ...
- SPOJ 1043 GSS1 - Can you answer these queries I
题目描述 给出了序列A[1],A[2],-,A[N]. (a[i]≤15007,1≤N≤50000).查询定义如下: 查询(x,y)=max{a[i]+a[i+1]+-+a[j]:x≤i≤j≤y}. ...
- (转)剖析Linux文件编码的查看及修改
Linux文件编码的查看和修改都有不止一种做法,如果你需要在Linux中操作windows下的文件,那么很可能会经常遇到文件编码转换的问题,如何进行这项工作,也应该是经常工作在双系统下的操作者的必须掌 ...
- MyEclipse使用总结——将原有的MyEclipse中的项目转成maven项目[转]
前面一篇文章中我们了解了 在myeclipse中新建Maven框架的web项目 那么如果我们原来有一些项目现在想转成maven项目应该怎么做呢 我收集到了三种思路: 一.新建一个maven项目,把原项 ...
- java基础之静态代码块,局部代码块,构造代码块区别。
java中有几种常见的代码块,那怎样区别他们呢? 这里就这些问题,浅谈下我个人的理解. 1.局部代码块 局部代码块,又叫普通代码块.它是作用在方法中的代码块.例如: public void show( ...