祖玛

DS双向链表—祖玛

让人想犯罪 __ 提交于 2020-01-10 20:48:05
题目描述 祖玛是一款曾经风靡全球的游戏,其玩法是:在一条轨道上初始排列着若干个彩色珠子,其中任意三个相邻的珠子不会完全同色。此后,你可以发射珠子到轨道上并加入原有序列中。一旦有三个或更多同色的珠子变成相邻,它们就会立即消失。这类消除现象可能会连锁式发生,其间你将暂时不能发射珠子。 给定轨道上初始的珠子序列,然后是玩家所做的一系列操作。你的任务是,在各次操作之后及时计算出新的珠子序列。 输入 第一行是一个由大写字母'A'~'Z'组成的字符串,表示轨道上初始的珠子序列,不同的字母表示不同的颜色。 第二行是一个数字n,表示玩家共有n次操作。 接下来的n行依次对应于各次操作。每次操作由一个数字k和一个大写字母描述,以空格分隔。其中,大写字母为新珠子的颜色。若插入前共有m颗珠子,位置0-m-1,则k ∈ [0, m]表示新珠子嵌入在轨道上的位置。 输出 输出共n行,依次给出各次操作(及可能随即发生的消除现象)之后轨道上的珠子序列。 如果轨道上已没有珠子,则以“-”表示。 样例输入 ACCBA 5 1 B 0 A 2 B 4 C 0 A 样例输出 ABCCBA AABCCBA AABBCCBA - A 提示 #include<iostream> #include<string> #include<cstdio> #include<cstring> using namespace std;

祖玛(Zuma)

你。 提交于 2019-11-30 00:47:00
祖玛(Zuma) Description Let's play the game Zuma! There are a sequence of beads on a track at the right beginning. All the beads are colored but no three adjacent ones are allowed to be with a same color. You can then insert beads one by one into the sequence. Once three (or more) beads with a same color become adjacent due to an insertion, they will vanish immediately. Note that it is possible for such a case to happen for more than once for a single insertion. You can't insert the next bead until all the eliminations have been done. Given both the initial sequence and the insertion series, you