String Manipulation 1.0

Time Limit: 3000ms
Memory Limit: 262144KB

This problem will be judged on CodeForces. Original ID: 159C
64-bit integer IO format: %I64d      Java class name: (Any)

One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number p and character c and delete the p-th occurrence of character c from the name. After the user changed his name, he can't undo the change.

For example, one can change name "arca" by removing the second occurrence of character "a" to get "arc".

Polycarpus learned that some user initially registered under nickname t, where t is a concatenation of k copies of string s. Also, Polycarpus knows the sequence of this user's name changes. Help Polycarpus figure out the user's final name.

 

Input

<p< p="">

The first line contains an integer k (1 ≤ k ≤ 2000). The second line contains a non-empty string s, consisting of lowercase Latin letters, at most 100characters long. The third line contains an integer n (0 ≤ n ≤ 20000) — the number of username changes. Each of the next n lines contains the actual changes, one per line. The changes are written as "pi ci" (without the quotes), where pi (1 ≤ pi ≤ 200000) is the number of occurrences of letter cici is a lowercase Latin letter. It is guaranteed that the operations are correct, that is, the letter to be deleted always exists, and after all operations not all letters are deleted from the name. The letters' occurrences are numbered starting from 1.

 

Output

<p< p="">

Print a single string — the user's final name after all changes are applied to it.

 

Sample Input

<p< p=""><p< p="">

Input
2
bac
3
2 a
1 b
2 c
Output
acb
Input
1
abacaba
4
1 a
1 a
1 c
2 b
Output
baa

Hint

<p< p="">

Let's consider the first sample. Initially we have name "bacbac"; the first operation transforms it into "bacbc", the second one — to "acbc", and finally, the third one transforms it into "acb".

 

Source

 
解题:直接用线段树记录二十六个字母分别的出现位置。。。
 
 #include <bits/stdc++.h>
using namespace std;
const int maxn = ;
int tree[][maxn<<],k,n,p;
bool isdel[maxn];
string str,s,c;
void pushup(int wd,int v) {
tree[wd][v] = tree[wd][v<<] + tree[wd][v<<|];
}
void update(int L,int R,int wd,int id,int v) {
if(L == R) {
tree[wd][v]++;
return;
}
int mid = (L + R)>>;
if(id <= mid) update(L,mid,wd,id,v<<);
if(id > mid) update(mid+,R,wd,id,v<<|);
pushup(wd,v);
}
void del(int L,int R,int wd,int v,int rk){
if(L == R) {
tree[wd][v]--;
isdel[L] = true;
return;
}
int mid = (L + R)>>;
if(tree[wd][v<<] >= rk) del(L,mid,wd,v<<,rk);
else del(mid+,R,wd,v<<|,rk-tree[wd][v<<]);
pushup(wd,v);
}
int main() {
cin.sync_with_stdio(false);
cin>>k>>s>>n;
str = "";
for(int i = ; i < k; ++i) str += s;
int len = str.length();
for(int i = ; i < len; ++i)
update(,len-,str[i]-'a',i,);
while(n--){
cin>>p>>c;
del(,len-,c[]-'a',,p);
}
for(int i = ; i < len; ++i)
if(!isdel[i]) cout<<str[i];
cout<<endl;
return ;
}

CodeForces 159c String Manipulation 1.0的更多相关文章

  1. VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 字符串模拟

    C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/pr ...

  2. string manipulation in game development-C # in Unity -

    ◇ string manipulation in game development-C # in Unity - It is about the various string ● defined as ...

  3. Entity Framework 6 执行Linq to Entities异常"p__linq__1 : String truncation: max=0, len=2, value='测试'"

    场景再现 我需要查询公司名称包含给定字符串的公司,于是我写了下面的测试小例子: var condition = "测试"; var query = from b in db.Com ...

  4. Bash String Manipulation Examples – Length, Substring, Find and Replace--reference

    In bash shell, when you use a dollar sign followed by a variable name, shell expands the variable wi ...

  5. weblogic部署异常: cvc-enumeration-valid: string value '3.0' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee:<null>

    尝试使用weblogic部署一个Demo应用,在选择应用目录后,报出下面的异常: VALIDATION PROBLEMS WERE FOUND problem: cvc-enumeration-val ...

  6. String字符串补0操作常见方法

     String前补0 java的String字符串补0或空格 方法一:自己写的方法 /* *数字不足位数左补0** @param str* @param strLength*/public stati ...

  7. string 从下标0 一直截到倒数第三位

    StringUtils.substring(String.valueOf(maxSequence), 0, -3)如上,关键就是那个-3,表示倒数第三位.

  8. vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". Expected String with value "0", got Number with value 0.

    vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". ...

  9. CodeForces 779D. String Game(二分答案)

    题目链接:http://codeforces.com/problemset/problem/779/D 题意:有两个字符串一个初始串一个目标串,有t次机会删除初始串的字符问最多操作几次后刚好凑不成目标 ...

随机推荐

  1. ES6学习笔记(十四)Generator函数

    清明时节雨纷纷,路上行人欲断魂. 借问酒家何处有,牧童遥指杏花村. 二零一九年农历三月初一,清明节. 1.简介 1.1.基本概念 Generator 函数也是 ES6 提供的一种异步编程解决方案,据说 ...

  2. 用Electron开发企业网盘(二)--分片下载

    书接上文,背景见:https://www.cnblogs.com/shawnyung/p/10060119.html HTTP请求头  Range 请求资源的部分内容(不包括响应头的大小),单位是by ...

  3. Windows10通过VNC远程连接Ubuntu18.04

    1.打开终端输入:sudo apt-get install xrdp vnc4server xbase-clients dconf-editor 2.接着在终端输入: 进入到下面这个界面: 接着按照这 ...

  4. Unity ContextMenu特性

    有时候我们需要在编辑器下,频繁的做一些操作,比如说在不同的位置创建物体,一个个的修改坐标显然有点繁琐 这时候ContextMenu就派上用处了 例:利用 LineRenderer 画圆,我们不可能一个 ...

  5. 【Henu ACM Round#18 F】Arthur and Walls

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 考虑,为什么一个连通块里面的空格没有变成一个矩形? 如果不是形成矩形的话. 肯定是因为某个2x2的单张方形里面. 只有一个角是墙.其 ...

  6. 洛谷 P3152 正整数序列

    P3152 正整数序列 题目描述 kkk制造了一个序列,这个序列里的数全是由正整数构成的.你别认为她的数列很神奇——其实就是1, 2, …, n而已.当然,n是给定的.kkk的同学lzn认为0是一个好 ...

  7. Nutch1.6学习笔记

    回 到 目 录 暑假每天傍晚或晚上更新 伪恋赛高 这里提供nutch1.6的src下载: apache-nutch-1.6-src.zip 115网盘礼包码:5lbcymlo6u76http://11 ...

  8. [Python] Boolean Or "Mask" Index Arrays filter with numpy

    NumPy Reference: Indexing Integer array indexing Boolean array indexing Note: The expression a < ...

  9. HDU 5389 Zero Escape(DP + 滚动数组)

    Zero Escape Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) To ...

  10. rman数据库恢复;关键/非重要文件、影像副本、控制文件、还原点、非归档、增量、新数据库、灾难性回复

    运行全然恢复:在 ARCHIVELOG 模式下 丢失了系统重要数据文件: 假设某个数据文件丢失或损坏.且该文件属于 SYSTEM 或 UNDO 表空间,请运行下面步骤: 1. 实例可能会也可能不会自己 ...