Keyboard Layouts

题目链接http://codeforces.com/problemset/problem/831/B

B. Keyboard Layouts
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.

You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in the same order.

You are also given some text consisting of small and capital English letters and digits. It is known that it was typed in the first layout, but the writer intended to type it in the second layout. Print the text if the same keys were pressed in the second layout.

Since all keys but letters are the same in both layouts, the capitalization of the letters should remain the same, as well as all other characters.

Input

The first line contains a string of length 26 consisting of distinct lowercase English letters. This is the first layout.

The second line contains a string of length 26 consisting of distinct lowercase English letters. This is the second layout.

The third line contains a non-empty string s consisting of lowercase and uppercase English letters and digits. This is the text typed in the first layout. The length of s does not exceed 1000.

Output

Print the text if the same keys were pressed in the second layout.

Examples
input
qwertyuiopasdfghjklzxcvbnm
veamhjsgqocnrbfxdtwkylupzi
TwccpQZAvb2017
output
HelloVKCup2017
input
mnbvcxzlkjhgfdsapoiuytrewq
asdfghjklqwertyuiopzxcvbnm
7abaCABAABAcaba7
output
7uduGUDUUDUgudu7

题目大意:

输入三个字符串,第一个字符串表示第一个键盘的布局,第二个字符串表示第二种键盘的布局,第三个字符串是 文本 。题目要求 按照第一种键盘输入文本,用第二种键盘输出文本(其中数字原样输出;如果源文本中为大写字母,则输出文本的也应该是大写字母;如果源文本中为小写字母,则输出文本也应该是小写字母)。

解题思路:

对源文本进行遍历,用一个变量标记源文本字母 对应于 第一种键盘出现的下标,然后根据源文本中字母的大小写,输出对应于第二种键盘输出的文本(也就是要输出的文本)。

代码:

#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s1,s2,s3;
    int z;
    while(cin>>s1>>s2>>s3)
    {
        for(int i=0;i<=s3.size()-1;i++)               //对源文本进行遍历
        {
            if(s3[i]>='0' && s3[i]<='9')              //如果是数字,则直接输出
            {
                cout<<s3[i];
                continue;
            }
            for(int j=0;j<=s1.size()-1;j++)           //查找并标记源文本对应于第一种键盘出现的位置(也就是数组下标)
            {
                if(s1[j]==s3[i] || s3[i]+32==s1[j])
                {
                    z=j;
                    break;
                }
            }
            if(s3[i]>='a' && s3[i]<='z')            //如果源文本为小写字母
            {
                if(s2[z]>='a' && s2[z]<='z')
                    cout<<s2[z];
                else
                {
                    s2[z]=s2[z]+32;
                    cout<<s2[z];
                }
            }
            else                                   //如果源文本为大写字母
            {
                if(s2[z]>='A' && s2[z]<='Z')
                    cout<<s2[z];
                else
                {
                    s2[z]=s2[z]-32;
                    cout<<s2[z];
                }
            }
        }
        cout<<endl;
    }
    return 0;
}


<think>好的,我现在遇到了PyCharm提示“Keyboard Layouts: duplicate keyboard layout identifier -14934. Keyboard Layouts: keyboard layout identifier -14934 has been replaced with -28675.”这个问题。我需要先理解这个错误信息到底是什么意思。首先,错误提到了键盘布局标识符重复,具体是-14934被替换成了-28675。这说明PyCharm在加载键盘布局时发现了冲突,于是自动替换了一个新的标识符。 接下来,我需要考虑可能的原因。键盘布局标识符通常是用来唯一识别不同键盘配置的,如果出现重复,可能是因为安装了多个键盘布局,或者某些配置文件被重复生成或损坏。可能的情况包括: 1. **重复的键盘布局配置**:可能用户或者某些程序不小心添加了相同的键盘布局,导致ID冲突。 2. **PyCharm配置文件问题**:PyCharm本身的配置文件可能损坏,或者旧的配置没有正确清理,导致重复的标识符。 3. **系统级键盘布局冲突**:操作系统级别的键盘布局设置可能有冲突,影响到PyCharm的识别。 然后,我需要思考解决方案。根据常见的类似问题,可能的解决步骤包括: - **重启PyCharm和计算机**:有时候临时的问题可以通过重启应用或系统解决,尤其是如果配置文件被错误地缓存。 - **检查并清理键盘布局配置**:查看PyCharm的配置目录,删除可能重复或损坏的键盘布局文件。比如在Windows下,可能是在用户目录下的.PyCharm相关文件夹里。 - **重置PyCharm设置**:如果问题持续,尝试重置PyCharm的配置到默认状态,这样可以清除所有可能导致冲突的自定义设置。 - **检查系统键盘布局**:在系统设置中查看是否有重复或不需要的键盘布局,删除多余的配置。 - **更新或重新安装PyCharm**:确保使用的是最新版本,或者尝试重新安装以修复可能的安装问题。 同时,我需要验证这些步骤的可行性。例如,清理配置文件可能需要找到具体的目录路径,不同操作系统下路径不同。而重置设置可能会丢失一些个性化配置,需要提前备份。此外,系统键盘布局的管理在不同操作系统(如Windows、macOS、Linux)中方法不同,需要用户根据实际情况调整。 可能还需要考虑用户是否有安装第三方插件或自定义的键盘映射,这些也有可能导致冲突。因此,建议用户检查最近安装的插件或进行的配置更改,尝试禁用插件以排查问题。 最后,确保用户理解这些步骤的目的,避免误操作导致其他问题。比如,删除配置文件前应备份,重置设置前导出重要配置等。如果问题依然存在,建议用户查看PyCharm的官方支持论坛或提交问题报告,以获取更专业的帮助。</think>PyCharm提示的键盘布局标识符重复问题通常由配置文件冲突引起。以下是逐步解决方案: **问题本质分析**: - 错误代码`-14934`和`-28675`属于PyCharm内部键盘布局标识符 - 系统检测到重复的键盘映射配置时自动执行标识符替换 **解决步骤**: 1. **基础排查** ```shell # 强制退出PyCharm并清理缓存(macOS示例) rm -rf ~/Library/Caches/JetBrains/PyCharm* ``` - Windows路径:`C:\Users\<用户名>\AppData\Local\JetBrains\PyCharm<版本>\` - Linux路径:`~/.cache/JetBrains/PyCharm<版本>/` 2. **配置文件重置** ```shell # 备份后删除配置文件(所有系统通用) mv ~/.PyCharm<版本> ~/.PyCharm<版本>_backup ``` 3. **键盘布局管理** - 打开系统设置 → 语言与输入 → 删除多余键盘布局 - 检查`$HOME/.Xkbmap`(Linux)或注册表`HKEY_CURRENT_USER\Keyboard Layout`(Windows) 4. **版本维护** ```shell # 检查更新(通过JetBrains Toolbox) jb_toolbox update pycharm ``` - 或使用IDE内置更新:`Help → Check for Updates` **高级处理方案**: ```java // 查看PyCharm底层键盘映射日志(需开启内部模式) idea.log.path=/path/to/idea.log grep "KeyboardLayout" idea.log ``` **预防措施**: 1. 避免同时安装多个语言包插件 2. 定期执行`File → Invalidate Caches / Restart` 3. 使用标准键盘布局时禁用第三方输入法 **数学验证示例**: 当存在$n$个键盘布局时,唯一标识符应满足: $$ \forall i,j \in [1,n], \quad id_i \neq id_j \ (i \neq j) $$ 系统自动替换过程遵循: $$ id' = \begin{cases} id & \text{if } unique(id) \\ hash(name + config) & \text{otherwise} \end{cases} $$ 若问题仍存在,建议通过`Help → Collect Logs and Diagnostic Data`生成报告提交官方支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值