#abc199c. C - IPFL
C - IPFL
Score : points
问题描述
我们有一个长度为 的字符串 。
您将得到针对此字符串的 个查询操作。在第 个查询中,给定三个整数 , 和 ,执行以下操作:
- 如果 :交换 中第 个和第 个字符;
- 如果 :交换字符串 的前 个字符和后 个字符(此时 和 的值不使用)。
例如,如果 为
FLIP
,这个查询会让它变为IPFL
。
按照给出的顺序处理完所有 个查询后,打印字符串 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a string of length .
You are given queries on this string.
In the -th query, given three integers , , and , do the following:
- if : swap the -th and -th characters of ;
- if : swap the first characters and last characters of (the values and are not used).
For example, if isFLIP
, this query makes itIPFL
.
Print the string after processing all queries in the order they are given.
Constraints
- is a string of length consisting of uppercase English letters.
- is or .
- If , .
- If , .
Input
Input is given from Standard Input in the following format:
Output
Print the string after processing the queries.
Sample Input 1
2
FLIP
2
2 0 0
1 1 4
Sample Output 1
LPFI
The -st query swaps the first characters and last characters of , making it IPFL
.
The -nd query swaps the -st and -th characters of , making it LPFI
.
Sample Input 2
2
FLIP
6
1 1 3
2 0 0
1 1 2
1 2 3
2 0 0
1 1 4
Sample Output 2
ILPF