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/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[];
const int inf=0x3f3f3f3f;
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} //************************************************************************************** int check[maxn];
vector<int> kiss[];
string os,s;
int main()
{
int k=read();
cin>>os;
for(int i=;i<k;i++)
s+=os;
for(int i=;i<s.size();i++)
kiss[s[i]-'a'].push_back(i);
int n=read();
for(int i=;i<n;i++)
{
int a;
char b;
cin>>a>>b;
check[kiss[b-'a'][a-]]=;
kiss[b-'a'].erase(kiss[b-'a'].begin()+a-);
}
for(int i=;i<s.size();i++)
if(!check[i])
cout<<s[i]; }
上一篇:hadoop HA sshfen切换隔离时无法跳转ssh: bash: fuser: 未找到命令


下一篇:atcoder 它February 29th