【PAT甲级】1084 Broken Keyboard (20 分)
题意:
输入两行字符串,输出第一行有而第二行没有的字符(对大小写不敏感且全部以大写输出)。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
bool vis[];
vector<char>ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>s1>>s2;
int n=s1.size();
int p=;
int pos=;
for(int i=;i<n;++i){
if(s1[i]==s2[p])
++p;
else if(!vis[s1[i]-'']){
if(s1[i]>='a'&&s1[i]<='z')
ans.push_back(s1[i]-'a'+'A');
else
ans.push_back(s1[i]);
vis[s1[i]-'']=;
if(s1[i]>='a'&&s1[i]<='z')
vis[s1[i]-'a'+'A'-'']=;
else if(s1[i]>='A'&&s1[i]<='Z')
vis[s1[i]-'A'+'a'-'']=;
}
if(p==s2.size()){
pos=i+;
break;
}
}
for(int i=pos;i<n;++i)
if(!vis[s1[i]-'']){
ans.push_back(s1[i]);
vis[s1[i]-'']=;
if(s1[i]>='a'&&s1[i]<='z')
vis[s1[i]-'a'+'A'-'']=;
else if(s1[i]>='A'&&s1[i]<='Z')
vis[s1[i]-'A'+'a'-'']=;
}
for(auto it:ans)
cout<<it;
return ;
}
【PAT甲级】1084 Broken Keyboard (20 分)的更多相关文章
- PAT Advanced 1084 Broken Keyboard (20) [Hash散列]
题目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the charact ...
- 1084. Broken Keyboard (20)【字符串操作】——PAT (Advanced Level) Practise
题目信息 1084. Broken Keyboard (20) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B On a broken keyboard, some of ...
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)
1046 Shortest Distance (20 分) The task is really simple: given N exits on a highway which forms a ...
- PAT 甲级 1042 Shuffling Machine (20 分)(简单题)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is de ...
随机推荐
- (转)数据库分片Shard操作
2.1.1什么是数据切分 "Shard" 这个词英文的意思是"碎片",而作为数据库相关的技术用语,似乎最早见于大型多人在线角色扮演游戏中."Shard ...
- linux复制,网络报错
我拷贝了过来的Linux虚拟机无法上网,我用ifconfig命令查询了一下发现只有eth1和lo设备,没有eth0.于是我在Google上搜索了一下, <VMWare克隆或复制Linux虚拟机后 ...
- ssh: connect to git@gitlab.xxxxx.com:xxxxx.git port 22: Connection refused
公司服务器上的gitlab项目添加了ssh密钥,但是操作时却报错ssh: connect to git@gitlab.xxxxx.com:xxxxx.git port 22: Connection r ...
- MonkeyRunner Mac环境 录制脚本和回放 批量回放
1.MonkeyRunner是AndroidSDK自带的一个东西,在SDK目录中的tools\bin文件夹中 2.配置环境变量 编辑环境变量:打开终端输入:open ~/.bash_profile 将 ...
- 第k个数(排序)
给定一个长度为n的整数数列,以及一个整数k,请用快速选择算法求出数列的第k小的数是多少. 输入格式 第一行包含两个整数 n 和 k. 第二行包含 n 个整数(所有整数均在1~109109范围内),表示 ...
- 开发笔记—钉钉服务商应用isv开发,从应用配置,到获取客户企业通讯录
以第三方企业微应用为例 在第三方企业微应用应用时,比较底层的需求,就是应用需要获取客户企业的通讯录,即部门/员工的数据.本人整理以下几个关键数据,供大家开发参考. 新建第三方微应用时,能拿到这些初始数 ...
- Django框架中auth模块的详解
auth模块 auth模块是对登录认证方法的一种封装,本身就是一个对象,可以获取用户的详细信息,有了auth模块可以验证登录信息是否存在数据库中,还可以检验用户是否已经登录,校验密码等 auth方法 ...
- python文件读取:遇见的错误及解决办法
问题一: TypeError: 'str' object is not callable 产生原因: 该错误TypeError: 'str' object is not callable字面上意思:就 ...
- Vue-cli3 项目配置 Vue.config.js( 代替vue-cli2 build config)
Vue-cli3 搭建的项目 界面相对之前较为简洁 之前的build和config文件夹不见了,那么应该如何配置 如webpack等的配那 只需要在项目的根目录下新建 vue.config.js 文件 ...
- IDEA中进行远程调试springboot项目
1.以debug的模式启动Springboot项目 命令 java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8888,suspe ...