C. String Manipulation 1.0

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

codeforces.com/problemset/problem/91/B

Description

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

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 100 characters 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 ci, ci 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

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

Sample Input

2
bac
3
2 a
1 b
2 c

Sample Output

acb

HINT

题意

题解:

代码

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 2000001
#define mod 1000000007
#define eps 1e-9
int Num;
char CH[20];
const int inf=0x3f3f3f3f;
inline ll read()
{int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}//**************************************************************************************int check[maxn];
vector<int> kiss[30];
string os,s;
int main()
{int k=read();cin>>os;for(int i=0;i<k;i++)s+=os;for(int i=0;i<s.size();i++)kiss[s[i]-'a'].push_back(i);int n=read();for(int i=0;i<n;i++){int a;char b;cin>>a>>b;check[kiss[b-'a'][a-1]]=1;kiss[b-'a'].erase(kiss[b-'a'].begin()+a-1);}for(int i=0;i<s.size();i++)if(!check[i])cout<<s[i];}

VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 字符串模拟相关推荐

  1. VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 线段树 or 树状数组+二分

    http://codeforces.com/problemset/problem/159/C 题意: 给你一个字符串s,给出一个数k,k倍的s串组成新串str.然后给出n个操作,每个操作对应着pi,c ...

  2. VK Cup 2015 - Qualification Round 1 A. Reposts(树)

    传送门 Description One day Polycarp published a funny picture in a social network making a poll about t ...

  3. VK Cup 2012 Round 1 D. Distance in Tree (树形dp)

    题目:http://codeforces.com/problemset/problem/161/D 题意:给你一棵树,问你两点之间的距离正好等于k的有多少个 思路:这个题目的内存限制首先大一倍,他有5 ...

  4. 【树形dp】VK Cup 2012 Round 1 D. Distance in Tree

    统计树中长度为K的路径条数. 用f[u][k]表示从u结点的子树中出发,终止于u结点的长度为k的路径条数. 边dp边统计答案.为了防止重复统计,在枚举子节点的时候,先将该子节点和当前u结点(和前面已经 ...

  5. Facebook Hacker Cup 2016 Qualification Round 解题报告

    Boomerang Constellations 题意: 给定N≤2×103个点,求满足dis(x,y)=dis(y,z)的三元组(x,y,z)个数,(x,y,z)与(z,y,x)被认为是相同的给定N ...

  6. codeforces VK Cup 2018 - Wild-card Round 1 (unofficial unrated mirror)

    开开心心的打开codeforces, 本来打算疯狂AC一波,结果开了这一场,进去一看题好简单呀,火速交一发,结果交第二题的时候提示不让我交了??????????? 提示每种语言只能AC一道题,ok,难 ...

  7. Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimination Round, Engine) C. Restoring

    C. Restoring Permutation time limit per test1 second memory limit per test256 megabytes inputstandar ...

  8. Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimination Round, Engine) A Dead Pixel

    讨论坏点的左右上下的矩形大小. #include <bits/stdc++.h> using namespace std; int main() {int t;cin >> t ...

  9. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...

最新文章

  1. Office 365系列(3)------Office 365认证使用ADFS安装部署参考
  2. sqlserver ADO.net 查询数据库加锁,事务提交
  3. 自动化集成:Pipeline整合Docker+K8S
  4. windows下使用cmake+mingw配置makefile(2)
  5. 一文彻底搞懂线程安全问题
  6. 4位先行进位电路 logisim_数字电路基础之逻辑电路
  7. mvc路由原理 php_PHP实战002:CodeIgniter安装和入门使用
  8. libevhtp介绍与demo构建
  9. 梯度下降法与正规方程的比较
  10. 视频教程-VB程序设计教程:从入门到精通-计算机等级考试
  11. 关于华为宣讲的一些感悟
  12. JavaScript实用手册
  13. Unity修改编辑器
  14. ### LinuxCBT VBOX Edition ###
  15. Maya根据模型建立乐高模型
  16. 设计模式(四)工厂模式
  17. python txt文本转json格式
  18. ANSYS FLUENT 超临界流体物性分段线性插值数据批量导入
  19. 分布式数据库服务器时钟同步(NTP网络时钟同步)北斗卫星同步时钟起到关键性作用
  20. Android数据加密传输

热门文章

  1. linux shell let命令,shell编程中的let与(())
  2. php4.3-5.x,4.3 案例之 ThinkPHP 5.0 集成方法
  3. android sdk版本控制,1. 统一SDK版本管理配置
  4. PHP中switch条件语句的使用,php条件语句(2)switch...case语句
  5. Markdown 编辑器的使用记录 (Typora)
  6. 【 MATLAB 】DFS 与 z 变换之间的关系
  7. Redis Labs再次修改许可,没用几个月的Commons Clause或被删除
  8. 设置本地用户帐户的过期日期
  9. Spring Boot中Web应用的统一异常处理
  10. 自己封装JSTL 自定义标签