luogu#P4415. [COCI2006-2007#2] KOLONE

[COCI2006-2007#2] KOLONE

题目描述

When moving, ants form rows so that each ant except the first is behind another ant. It is not widely known what happens when two rows of ants moving in opposite directions run into each other in a passage too narrow for both rows to pass through. One theory says that, in that situation, ants will jump over each other. From the moment the rows meet, each second every ant jumps over (or gets jumped over, as they agree upon) the ant in front of himself so that the two ants swap places, but only if the other ant is moving in the opposite direction. Find the order of the ants after T seconds.

输入格式

The first line contains two integers N1 and N2, the numbers of ants in the first and second rows, respectively. The next two rows contain the orders of ants in the first and second row (first to last). Each ant is uniquely determined by an uppercase letter of the English alphabet (this letter is unique between both rows). The last line of input contains the integer T (0 ≤ T ≤ 50).

输出格式

Output the order of the ants after T seconds on a single line. Our viewpoint is such that the first row of ants comes from our left side and the other one from our right side.

题目大意

当蚂蚁移动时,蚂蚁排成一行,每个蚂蚁除了第一个蚂蚁都在另一个蚂蚁后面。众所周知,当两排蚂蚁在相反的方向上移动时,在一条太窄的通道中,两排都不能通过。一种理论认为,在这种情况下,蚂蚁会跳过对方。每隔一段时间,每一个蚂蚁都会跳过(或跳过去,就像他们同意的一样)蚂蚁在自己前面,这样两个蚂蚁交换位置,但是只有当另一只蚂蚁朝相反的方向移动时。在T秒后找到蚂蚁的顺序。 输入格式: 第一行包含两个整数N1和N2,分别在第一行和第二行中的蚂蚁的数量。接下来的两行包含第一行和第二行中的蚂蚁顺序(第一到最后一行)。每一个蚂蚁都是由一个大写字母(英文字母)唯一决定的(这两个字母在两行之间是唯一的)。输入的最后一行包含整数T(T小于50)。 输出格式: 在一条线上输出T秒后蚂蚁的顺序。我们的观点是,第一排蚂蚁来自我们的左侧,另一个来自我们的右侧。

感谢@心之所爱 提供的翻译

3 3
ABC
DEF
0
CBADEF
3 3
ABC
DEF
2
CDBEAF
3 4
JLA
CRUO
3
CARLUJO