#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的更多相关文章

  1. POJ 2887 Big String(块状链表)

    题目大意 给一个字符串,长度不超过 106,有两种操作: 1. 在第 i 个字符的前面添加一个字符 ch 2. 查询第 k 个位置是什么字符 操作的总数不超过 2000 做法分析 好多不同的做法都可以 ...

  2. poj 2887 Big String

    题目连接 http://poj.org/problem?id=2887 Big String Description You are given a string and supposed to do ...

  3. POJ 2887:Big String(分块)

    http://poj.org/problem?id=2887 题意:给出一个字符串,还有n个询问,第一种询问是给出一个位置p和字符c,要在位置p的前面插入c(如果p超过字符串长度,自动插在最后),第二 ...

  4. Poj 2887 Big String(块状数组)

    Big String Time Limit: 1000MS Memory Limit: 131072K Description You are given a string and supposed ...

  5. POJ 2887 Big String (块状数组)

    题意:给一个字符串(<=1000000)和n个操作(<2000),每个操作可以在某个位置插入一个字符,或者查询该位置的字符.问查询结果. 思路:块状数组. 如果将原来的字符串都存在一起,每 ...

  6. 好题 线段树对数据的保存+离线的逆向插入 POJ 2887

    题目大意:给一个字符串,有插入和询问操作,每次往一个位置插入一个字符或者询问第p个位置的字符是什么. 思路:我们离线询问,逆向把所有的字符都插入给线段树,然后再查询就好了,每次都要记得插入线段树的最后 ...

  7. Big String(poj 2887)

    题意: 给你一个不超过1e6的字符串,和不超过2000次的操作 操作分为两种: 1.将一个字符插入到某个位置的前面 2.询问当前位置的字符 /* 块状链表模板水题(我的智商也就能做这种题了). 观察题 ...

  8. Poj 2887-Big String Splay

    题目:http://poj.org/problem?id=2887       Big String Time Limit: 1000MS   Memory Limit: 131072K Total ...

  9. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

随机推荐

  1. Linux关机操作

    正确的关机流程为:sync > shutdown > reboot > halt 关机指令为:shutdown ,你可以man shutdown 来看一下帮助文档. 例如你可以运行如 ...

  2. LOJ-10099(点双联通)

    题目链接:传送门 思路: 如果图是点双联通的,即没有割点,直接从图中随意选两个点即可: 如果有一个割点,删除割点,求连通块的个数即可(在每个连通块内新建一个营救点). 如果有多个割点,则可以通过其他割 ...

  3. ant Design和ant Design mobile的使用,并实现按需加载

    1.全局安装yarn npm install -g create-react-app yarn 2.创建react项目,并用yarn start 运行 3.引入antd/引入antd-mobile y ...

  4. centos 下备份oracle数据

    一.在xshell下root用户登录服务器 1.新建oracle数据库备份目录 mkdir -p /casnw/backup/oradata6910bak 2.设置目录权限为oinstall用户组的o ...

  5. win8快捷键大全分享,非常全

    Windows 8全新的Metro操作体验,对于没有平板只能用快捷键来提高效率了.全面的Windows 8快捷键,请下载微软官方的Windows 8快捷键表格,快捷键全记完整个人都斯巴达了..其实常用 ...

  6. 第01章:MongoDB简介

    ①MongoDB是什么 MongoDB是一个使用C++编写的.开源的.面向文档的NoSQL(Not Only SQL)数据库,也是当前最热门的NoSql数据库之一. ②MongoDB特点 1.高性能. ...

  7. linux内核链表使用

    原文链接:http://blog.csdn.net/xnwyd/article/details/7359373 Linux内核链表的核心思想是:在用户自定义的结构A中声明list_head类型的成员p ...

  8. 7-12 How Long Does It Take

    Given the relations of all the activities of a project, you are supposed to find the earliest comple ...

  9. MapServer和GeoServer对比

    https://blog.csdn.net/theonegis/article/details/45823099

  10. 如何更改linux文件的拥有者及用户组(chown和chgrp)

    http://blog.csdn.net/hudashi/article/details/7797393 一.基本知识   在Linux中,创建一个文件时,该文件的拥有者都是创建该文件的用户.该文件用 ...