VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 字符串模拟
2015-06-27 19:16
513 查看
C. String Manipulation 1.0
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
codeforces.com/problemset/problem/91/BDescription
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.
[b]Input[/b]
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.
[b]Output[/b]
Print a single string — the user's final name after all changes are applied to it.
[b]Sample Input[/b]
2
bac
3
2 a
1 b
2 c
[b]Sample Output[/b]
acb
HINT
[b]题意[/b]
[b]题解:[/b]
[b]代码[/b]
//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]; }
相关文章推荐
- 九部比《五十度灰》更血脉喷张的电影,个个看完都会让人欲罢不能!
- Eclipse安装SVN插件
- 设计模式系列--观察者模式基本
- Linux网络配置相关
- Vijava 学习笔记之数据中心下(集群和非集群的资源池和ESXI)树形结构展示
- A Statistical View of Deep Learning (IV): Recurrent Nets and Dynamical Systems
- highchart柱状图 series中data的数据构造
- mongoose学习笔记3--简单查询1
- C Prime plus 第六章习题
- uva 10047 The Monocycle
- DevExpress.Build
- 自定义View(视图)的创建、添加、移除细节分析
- 析构函数
- flash声音导入
- iOS 开发——CoreBluetooth蓝牙开发(一)
- 适合睡前阅读的书
- [第8章]算法设计技术——一维模式识别
- 自定义GridView/ListView数据源
- linux下一个eclipse组态jdk
- 华师大政治学系主任刘擎在2015年毕业典礼上的致辞