VK Cup Qualification Round 2 c. String manipulation 1.0 strings Simulation

Source: Internet
Author: User

C. String Manipulation 1.0

Time Limit:20 Sec

Memory limit:256 MB

Topic Connection

Codeforces.com/problemset/problem/91/b

Descriptionone Popular website developed an unusual username editing procedure. One can change the username-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 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 is written as "Pi Ci" (without the quotes), where PI (1≤pi≤200000) is the number of occurrences of CI, ci is a lowercase Latin letter. It is guaranteed that the operations was correct, that's, the letter to being deleted always exists, and after all operation s not all letters is deleted from the name. The letters ' occurrences is numbered starting from 1.

Output

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

Sample Input

2
Bac
3
2 A
1 b
2 C

Sample Output

Acb

HINT

Test instructions

Exercises

Code

//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>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 2000001#defineMoD 1000000007#defineEPS 1e-9intNum;Charch[ -];Const intinf=0x3f3f3f3f; inline ll read () {intx=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//**************************************************************************************intCheck[maxn];vector<int> kiss[ -];stringos,s;intMain () {intk=read (); CIN>>OS;  for(intI=0; i<k;i++) s+=OS;  for(intI=0; I<s.size (); i++) Kiss[s[i]-'a'].push_back (i); intn=read ();  for(intI=0; i<n;i++)    {        intA; Charb; CIN>>a>>b; Check[kiss[b-'a'][a-1]]=1; Kiss[b-'a'].erase (kiss[b-'a'].begin () +a-1); }     for(intI=0; I<s.size (); i++)        if(!Check[i]) cout<<s[i];}

VK Cup Qualification Round 2 c. String manipulation 1.0 strings Simulation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.