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 ...
随机推荐
- Django杂篇(2)
目录 Django杂篇(2) cookie与session cookie session django中间件 自定义中间件 跨站请求伪造(csrf) CSRF的解决方案 Django杂篇(2) 本文主 ...
- centos 7 开机启动服务项优化
1. 使用 systemctl list-unit-files 可以查看启动项 systemctl list-unit-files | grep enable 过滤查看启动项如下 abrt-ccpp. ...
- $.ajax()方法和$.get()方法使用小结
一. 使用JQuery的$.get()方法实现异步请求 1. 编写JSP <!DOCTYPE html> <html lang="en"> <head ...
- about how to determine a prime number
(1) if divided by 2 or 3, then no; (2) we only have to go through prime factors; because a composite ...
- 廖雪峰Java14Java操作XML和JSON-2JSON-2处理JSON
解析JSON JSR 353 API 常用的第三方库 * Jackson * gson * fastjson Jackson: 提供了读写JSON的API JSON和JavaBean可以互相转换 可食 ...
- 并发和多线程(四)--wait、notify、notifyAll、sleep、join、yield使用详解
wait.notify.notifyAll 这三个方法都是属于Object的,Java中的类默认继承Object,所以在任何方法中都可以直接调用wait(),notifyAll(),notify(), ...
- Go基础之函数递归实现汉诺塔
Go递归实现汉诺塔 package main import "fmt" // a 是源,b 借助, c 目的长度 func tower(a, b, c string, layer ...
- 为WCF增加UDP绑定(储备篇)
日前我开发的服装DRP需要用到即时通信方面的技术,比如当下级店铺开出零售单时上级机构能实时收到XX店铺XX时XX分卖出XX款衣服X件之类的信息,当然在上级发货时,店铺里也能收到已经发货的提醒.即时通信 ...
- 深入浅出Mybatis系列(六)---objectFactory、plugins、mappers简介与配置[转]
上篇文章<深入浅出Mybatis系列(五)---TypeHandler简介及配置(mybatis源码篇)>简单看了一下TypeHandler, 本次将结束对于mybatis的配置文件的学习 ...
- C++系列作业
1.编写一个完整的程序,实现功能:向用户提问“现在正在下雨吗?”,提示用户输入Y或N.若输入为Y,显示“现在正在下雨.”:若输入为N,显示“现在没有下雨”:否则继续提问“现在正在下雨吗?” #incl ...