CF1213E.Two Small Strings
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two strings s and t both of length 2 and both consisting only of characters 'a', 'b' and 'c'.
Possible examples of strings s and t: "ab", "ca", "bb".
You have to find a string res consisting of 3n characters, n characters should be 'a', n characters should be 'b' and n characters should be 'c' and s and t should not occur in res as substrings.
A substring of a string is a contiguous subsequence of that string. So, the strings "ab", "ac" and "cc" are substrings of the string "abacc", but the strings "bc", "aa" and "cb" are not substrings of the string "abacc".
If there are multiple answers, you can print any of them.
给你两个长度均为 2 的字符串 s 和 t,它们仅由字符 'a'、'b' 和 'c' 组成。
字符串 s 和 t 的一些可能示例:"ab"、"ca"、"bb"。
你需要构造一个长度为 3n 的字符串 res,其中恰好包含 n 个 'a'、n 个 'b' 和 n 个 'c',且 s 和 t 均不能作为 res 的子串出现。
字符串的子串是指该字符串的一个连续子序列。例如,字符串 "abacc" 的子串包括 "ab"、"ac" 和 "cc",但 "bc"、"aa" 和 "cb" 不是 "abacc" 的子串。
如果存在多个合法答案,输出任意一个即可。
输入格式
The first line of the input contains one integer n (1≤n≤105) — the number of characters 'a', 'b' and 'c' in the resulting string.
The second line of the input contains one string s of length 2 consisting of characters 'a', 'b' and 'c'.
The third line of the input contains one string t of length 2 consisting of characters 'a', 'b' and 'c'.
输入的第一行包含一个整数 n(1≤n≤105)——表示最终字符串中字符 'a'、'b' 和 'c' 的总个数。
输入的第二行包含一个长度为 2 的字符串 s,由字符 'a'、'b' 和 'c' 组成。
输入的第三行包含一个长度为 2 的字符串 t,由字符 'a'、'b' 和 'c' 组成。
输出格式
If it is impossible to find the suitable string, print "NO" on the first line.
Otherwise print "YES" on the first line and string res on the second line. res should consist of 3n characters, n characters should be 'a', n characters should be 'b' and n characters should be 'c' and s and t should not occur in res as substrings.
If there are multiple answers, you can print any of them.
如果无法找到满足条件的字符串,则在第一行输出 "NO"。
否则,在第一行输出 "YES",在第二行输出字符串 res。res 应当由 3n 个字符组成,其中恰好包含 n 个字符 'a'、n 个字符 'b' 和 n 个字符 'c',且 s 和 t 均不能作为子串出现在 res 中。
若存在多个合法答案,输出任意一个即可。
输入输出样例
输入#1
2 ab bc
输出#1
YES acbbac
输入#2
3 aa bc
输出#2
YES cacbacbab
输入#3
1 cb ac
输出#3
YES abc
输入解题思路,AI测评打分。不知道怎么写?