AT_abc469_g.K-nacci Operations
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given K strings S1,S2,…,SK consisting of a and b. Also, for an integer i>K, define the string Si as the concatenation of Si−1,Si−2,…,Si−K in this order.
You perform the following operation on a string T.
- Perform the following operations for j=1,2,…,∣SN∣ in order, where ∣SN∣ is the length of SN.
- If the j-th character of SN is
a, move the first character of T to the end. - If the j-th character of SN is
b, reverse T entirely. That is, reverse the order of the characters of T.
- If the j-th character of SN is
Find the string T after the series of operations.
给你 K 个仅由字符 a 和 b 组成的字符串 S1,S2,…,SK。此外,对任意大于 K 的整数 i,定义字符串 Si 为 Si−1,Si−2,…,Si−K 按此顺序拼接而成。
你将对字符串 T 执行如下操作:
- 对 j=1,2,…,∣SN∣(按此顺序),其中 ∣SN∣ 表示字符串 SN 的长度,执行以下操作:
- 若 SN 的第 j 个字符为
a,则将 T 的第一个字符移至末尾; - 若 SN 的第 j 个字符为
b,则将整个 T 反转(即反转 T 中所有字符的顺序)。
- 若 SN 的第 j 个字符为
求执行完全部操作后所得的字符串 T。
输入格式
The input is given from Standard Input in the following format:
K
S1
S2
⋮
SK
N
T
输入从标准输入给出,格式如下:
K
S1
S2
⋮
SK
N
T
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
3 a aa b 5 abc
输出#1
cab
输入#2
2 a ba 6 fibonacci
输出#2
canobific
输入#3
5 aba a bb ba aab 1000000000000000000 abcba
输出#3
aabcb
说明/提示
Sample 1 Explanation:
S1= a, S2= aa, S3= b, S4= baaa, and S5= baaabaa.
Through the operations, the string T changes as abc → cba → bac → acb → cba → abc → bca → cab, so the string T after the series of operations is cab.
Constraints
- 2≤K≤100
- K is an integer.
- Si is a non-empty string consisting of
aandb. (1≤i≤K) - The sum of the lengths of S1,S2,…,SK is at most 2×105.
- 1≤N≤1018
- N is an integer.
- T is a string consisting of lowercase English letters with length between 1 and 2×105, inclusive.
样例 1 解释:
S1= a,S2= aa,S3= b,S4= baaa,且 S5= baaabaa。
通过一系列操作,字符串 T 的变化过程为 abc → cba → bac → acb → cba → abc → bca → cab,因此经过全部操作后,字符串 T 为 cab。
限制条件
- 2≤K≤100
- K 是一个整数。
- Si 是由字符
a和b组成的非空字符串。(1≤i≤K) - S1,S2,…,SK 的长度总和不超过 2×105。
- 1≤N≤1018
- N 是一个整数。
- T 是一个由小写英文字母组成的字符串,其长度在 1 到 2×105(含)之间。
输入解题思路,AI测评打分。不知道怎么写?