#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. 简单实现java线程池

    使用多线程以及线程池的意义无需多说,要想掌握线程池,最好的方法还是自己手动去实现. 一.实现思路      (网络盗图) 二.实现代码 1.线程池类 package com.ty.thread; im ...

  2. Vue.js 教程

    http://www.runoob.com/vue2/vue-routing.html

  3. 修改oracle用户密码为永不过期

    错误提示:ORA-28001: the password has expired (DBD ERROR: OCISessionBegin) 解决方法:修改密码为永不过期 (1)查看用户的proifle ...

  4. prometheus+telegraf无法监控网络流量的问题

    原因是prometheus缺少以下紫色框的部分 解决办法: 比如要监控的机器ip为172.16.12.7,机器内部 安装了telegraf. 1)先查看机器的网卡:ifconfig 发现ip地址位于网 ...

  5. 阿里ETL工具datax学习(一)

    阿里云开源离线同步工具DataX3.0介绍 一. DataX3.0概览 ​ DataX 是一个异构数据源离线同步工具,致力于实现包括关系型数据库(MySQL.Oracle等).HDFS.Hive.Ma ...

  6. The file left unchanged.

    This files have types: *.___jb_old___ and *.___jb_bak___ The file left unchanged. You can disable &q ...

  7. oracle 监听文件 说明

    MAR:电脑笔记 不做整理 .. ORACLE_SID=orcl2 instance_name=sicca 静态注册文件中SID_NAME=ORACLE_SID 动态注册的时候是用的instance_ ...

  8. Stein算法求最大公约数

    首先引进一个符号:gcd是greatest common divisor(最大公约数)的缩写,gcd( x,y ) 表示x和y的最大公约数.然后有一个事实需要了解:一个奇数的所有约数都是奇数.这个很容 ...

  9. js五道经典练习题--第三道实现购物车功能

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  10. Ubuntu12.04搭建自有源

    其实,这个工作比较简单,主要两步:apt-mirror和apache.(这里的系统是ubuntu12.04) 1.apt-mirror 1.1 安装 一如既往地简单,直接sudo apt-get in ...