1298 : 连珠消除
时间限制Time Limit
1
秒Sec
内存限制Memory Limit
128
兆MB
提交次数Submitted
253 次Times
通过次数Solved
77 次Times
标准评测 Standard
从标准输入读入,结果写到标准输出。评测将输出拆成 token,与标准答案逐项比较,不按整段逐字节比对。
Read from standard input and write to standard output. The judge splits the output into tokens and compares them with the official answer; it does not compare raw bytes.
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
题目描述Description
水平轨道上有一系列珠子,至多有 \(A \sim C\) 共 \(26\) 种颜色,如果有 \(3\) 个或以上的同色珠子相邻,则会自动消除,剩下的珠子会重新连在一起,如果仍有可以消除的情况,则会连锁反应继续消除.
有一系列向其中插入珠子的操作,两次操作之间会等待所有连锁反应的消除完成.
输入格式Input
第一行为一个 \(A \sim C\) 组成的非空字符串,长度不超过 \(1000\),初始状态不存在可消除情况.
第二行 \(1 \leq m \leq 1000\) 表示 \(m\) 次插入操作.
接下来 \(m\) 行每行空格隔开两个字母,前一个字母表示插入位置为现有珠子从左向右第一次出现该颜色珠子位置之后,如果没有该颜色则插入到末尾. 第二个字母表示的插入的珠子颜色.
输出格式Output
输出一个字符串,表示所有操作结束后,从左到右的珠子颜色.
如果珠子已清空,则输出“-”.
样例Sample
出题Author
CSGrandeur