POJ 2887
#include <iostream>
#include <string>
#define MAXN 2000
using namespace std; struct node
{
char c;
int place;
}; node _node[MAXN]; int index;
void fun_q(int place);
int len;
string s;
int main()
{
//freopen("acm.acm","r",stdin); int op;
char c;
char c_1;
int q_place;
int i_place;
cin>>s;
cin>>op;
len = s.length();
index = 0; while(op --)
{
cin>>c;
if(c == 'Q')
{
cin>>q_place;
fun_q(q_place);
} else if(c == 'I')
{
cin>>c_1;
cin>>i_place;
if(i_place > len)
{
_node[index].c = c_1;
_node[index].place = len+1;
++ index;
++ len;
}
else
{
++ len;
_node[index].c = c_1;
_node[index].place = i_place;
++ index;
}
} }
} void fun_q(int place)
{ int i;
int p = place;
for(i = index-1; i >= 0; -- i)
{
// cout<<p<<"))))))))))))) "<<endl;
if(_node[i].place < p)
{
-- p;
}
else if(_node[i].place == p)
{
cout<<_node[i].c<<endl;
return;
}
}
cout<<s[p-1]<<endl;
}
POJ 2887的更多相关文章
- POJ 2887 Big String(块状链表)
题目大意 给一个字符串,长度不超过 106,有两种操作: 1. 在第 i 个字符的前面添加一个字符 ch 2. 查询第 k 个位置是什么字符 操作的总数不超过 2000 做法分析 好多不同的做法都可以 ...
- poj 2887 Big String
题目连接 http://poj.org/problem?id=2887 Big String Description You are given a string and supposed to do ...
- POJ 2887:Big String(分块)
http://poj.org/problem?id=2887 题意:给出一个字符串,还有n个询问,第一种询问是给出一个位置p和字符c,要在位置p的前面插入c(如果p超过字符串长度,自动插在最后),第二 ...
- Poj 2887 Big String(块状数组)
Big String Time Limit: 1000MS Memory Limit: 131072K Description You are given a string and supposed ...
- POJ 2887 Big String (块状数组)
题意:给一个字符串(<=1000000)和n个操作(<2000),每个操作可以在某个位置插入一个字符,或者查询该位置的字符.问查询结果. 思路:块状数组. 如果将原来的字符串都存在一起,每 ...
- 好题 线段树对数据的保存+离线的逆向插入 POJ 2887
题目大意:给一个字符串,有插入和询问操作,每次往一个位置插入一个字符或者询问第p个位置的字符是什么. 思路:我们离线询问,逆向把所有的字符都插入给线段树,然后再查询就好了,每次都要记得插入线段树的最后 ...
- Big String(poj 2887)
题意: 给你一个不超过1e6的字符串,和不超过2000次的操作 操作分为两种: 1.将一个字符插入到某个位置的前面 2.询问当前位置的字符 /* 块状链表模板水题(我的智商也就能做这种题了). 观察题 ...
- Poj 2887-Big String Splay
题目:http://poj.org/problem?id=2887 Big String Time Limit: 1000MS Memory Limit: 131072K Total ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
随机推荐
- 2018.11.07 hdu1465不容易系列之一(二项式反演)
传送门 其实标签只是搞笑的. 没那么难. 二项式反演只是杀鸡用牛刀而已. 这道题也只是让你n≤20n\le20n≤20的错排数而已. 还记得那个O(n)O(n)O(n)的递推式吗? 没错那个方法比我今 ...
- 2018.10.25 atcoder Leftmost Ball(计数dp+组合数学)
传送门 dp妙题啊. 我认为DZYODZYODZYO已经说的很好了. 强制规定球的排序方式. 然后就变成了一个求拓扑序数量的问题. 代码: #include<bits/stdc++.h> ...
- 实现1sym转换成2个sym送给CVI(VGA数据)
CVI的时序如下 :de指示数据有效. 从下面的程序看,同步码的长度不会影响对有效数据的判断.同步码的作用更多的是用于计算行及一行的像素数目.方案一: 1 module vga_1sym_2_2sym ...
- Docker mysql 主从
一.独立容器部署mysql主从 # 主从 my.cnf加上 [mysqld] server-id = XXX log-bin = mysql-bin log-bin-index = log-bin.i ...
- 第84讲:Scala中List和ListBuffer设计实现思考
今天来学习了scala中的list和ListBuffer scala list 内部很多操作是listbuffer做的,因为改变元素,listbuffer非常高效,tl是var类型的 ,但是他属于s ...
- U盘或者移动银盘退出时一直显示占用中问题解决--最粗暴解决方式
问题描述: ---------------------------弹出 USB 大容量存储设备 时出问题---------------------------Windows 无法停用“通用卷”设备,原 ...
- 牛客网2018暑期训练 第三场 a题
#include <bits/stdc++.h> using namespace std; vector<int> path; ; short dp[maxn][maxn][m ...
- Scala_函数式编程基础
函数式编程基础 函数定义和高阶函数 函数字面量 字面量包括整数字面量.浮点数字面量.布尔型字面量.字符字面 量.字符串字面量.符号字面量.函数字面量和元组字面量. scala> val i = ...
- HDU2732一个让我debug了一晚上的题目
思路都理解了,清晰了,就是代码不对,还是有些小地方自己注意不到,即使就在你的眼前也不易发现的那种 Description: 也是一个最大流的构图,没相出来,或者说想简单了也是标记点1 至 n * m是 ...
- 【并查集的另一个思考方向】POJ1456
POJ1456 这个题一看好像就是用贪心做啊,一个结构体,拍一下序,vis数组一遍遍扫荡,最后输出值,没错,贪心的确能做出来,而这类题目也能应用并查集,实现得思想也是贪心 #include <i ...