A8248 | Hockey
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name $w$ and the collection of forbidden substrings $s_{1},s_{2},...,s_{n}$ . All those strings consist of uppercase and lowercase Latin letters. String $w$ has the length of $|w|$ , its characters are numbered from $1$ to $|w|$ .
First Petya should find all the occurrences of forbidden substrings in the $w$ string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings "aBC" and "ABc" are considered equal.
After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position $i$ should be replaced by any other one if for position $i$ in string $w$ there exist pair of indices $l,r$ ( $1<=l<=i<=r<=|w|$ ) such that substring $w[l ... r]$ is contained in the collection $s_{1},s_{2},...,s_{n}$ , when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.
Letter $letter$ (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the $letter$ occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.
Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.
First Petya should find all the occurrences of forbidden substrings in the $w$ string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings "aBC" and "ABc" are considered equal.
After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position $i$ should be replaced by any other one if for position $i$ in string $w$ there exist pair of indices $l,r$ ( $1<=l<=i<=r<=|w|$ ) such that substring $w[l ... r]$ is contained in the collection $s_{1},s_{2},...,s_{n}$ , when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.
Letter $letter$ (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the $letter$ occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.
Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.
输入格式
The first line contains the only integer $n$ ( $1<=n<=100$ ) — the number of forbidden substrings in the collection. Next $n$ lines contain these substrings. The next line contains string $w$ . All those $n+1$ lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed $100$ . The last line contains a lowercase letter $letter$ .
输出格式
Output the only line — Petya's resulting string with the maximum number of letters $letter$ . If there are several answers then output the one that comes first lexicographically.
The lexicographical comparison is performed by the standard < operator in modern programming languages. The line $a$ is lexicographically smaller than the line $b$ , if $a$ is a prefix of $b$ , or there exists such an $i$ ( $1<=i<=|a|$ ), that $a_{i}<b_{i}$ , and for any $j$ ( $1<=j<i$ ) $a_{j}=b_{j}$ . $|a|$ stands for the length of string $a$ .
The lexicographical comparison is performed by the standard < operator in modern programming languages. The line $a$ is lexicographically smaller than the line $b$ , if $a$ is a prefix of $b$ , or there exists such an $i$ ( $1<=i<=|a|$ ), that $a_{i}<b_{i}$ , and for any $j$ ( $1<=j<i$ ) $a_{j}=b_{j}$ . $|a|$ stands for the length of string $a$ .
输入输出样例
输入 #1
3 bers ucky elu PetrLoveLuckyNumbers t
输出 #1
PetrLovtTttttNumtttt
输入 #2
4 hello party abefglghjdhfgj IVan petrsmatchwin a
输出 #2
petrsmatchwin
输入 #3
2 aCa cba abAcaba c
输出 #3
abCacba
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted