VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0
来源:互联网 发布:json encode 汉字 编辑:程序博客网 时间:2024/04/28 00:51
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.
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.
Print a single string — the user's final name after all changes are applied to it.
2bac32 a1 b2 c
acb
1abacaba41 a1 a1 c2 b
baa
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".
其实就是个水题。。但是比赛的时候没想到直接用一个数组存放用过的点,
关键是用vector对需要删除的点删除
下面是AC代码:
#include <iostream>#include <string>#include <vector>using namespace std;bool checked[200005];vector<int> occ[26];int main(){int K, N;string os, s = "";cin >> K >> os >> N;for (int i = 0; i < K; i++)s += os;for (int i = 0; i < s.size(); i++) occ[((int) s[i])-97].push_back(i);for (int i = 0; i < N; i++) {int oc, in;char c;cin >> oc >> c;in = ((int) c);checked[occ[in-97][oc-1]] = 1;occ[in-97].erase(occ[in-97].begin()+oc-1);}for (int i = 0; i < s.size(); i++)if (!checked[i]) cout << s[i];cout << endl;}
- VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0
- VK Cup 2015 - Qualification Round 2 C. Name Quest
- VK Cup 2015 - Qualification Round 2 C. Name Quest
- VK Cup 2016 - Qualification Round 2 C. Road Improvement dfs
- VK Cup 2012 Qualification Round 2 E 无语凝噎
- VK Cup 2012 Qualification Round 1 E
- VK Cup 2012 Qualification Round B题
- VK Cup 2012 Qualification Round 2部分题解(C,D,E)
- VK Cup 2012 Qualification Round 1--C. Cd and pwd commands
- Codeforces VK Cup 2012 Qualification Round 1 /158C (字符串处理)
- VK Cup 2012 Qualification Round 1---C. Cd and pwd commands
- cf#VK Cup 2015 - Qualification Round 2-C - Name Quest-贪心
- 【dp】VK Cup 2012 Qualification Round 1 ——E
- VK Cup 2012 Qualification Round 1 ( E Phone Talks)
- VK Cup 2012 Qualification Round 1 A题
- VK Cup 2012 Qualification Round 1 A题解题报告
- VK Cup 2012 Qualification Round 1 B. Taxi
- VK Cup 2012 Qualification Round 2--E. Zebra Tower 离散化+优先队列
- 向Google学习打造灵动的web体验
- lobo.py
- 【转】编译过程
- POJ 3735 Training little cats (快速求幂,稀疏矩阵)
- C语言测试(转载)
- VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0
- Struts2标签
- 2.14求数组的子数组之和的最大值
- PL/SQL developer 中文乱码问题
- Xcode 4.1/4.2/4.3 免证书(iDP)开发+真机调试+生成IPA全攻略
- XCode 真机测试发布时产生The executable was signed with invalid entitlements.解决办法之一
- Transact SQL Collection
- 非IDP万能证书真机测试,横扫一切SDK版本!
- PHP IIS "No input file specified." 错误