【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 ...
随机推荐
- COMMUNITY DETECTION
Method 1: M. E. J Newman ‘Networks: An Introduction’, page 224 Oxford University Press 2011. from ne ...
- CentOS 7升级gcc版本
Centos 7默认gcc版本为4.8,有时需要更高版本的,这里以升级至8.3.1版本为例,分别执行下面三条命令即可,无需手动下载源码编译 1.安装centos-release-scl sudo yu ...
- 配置Mongodb
MS Windows: 常用命令: 查看帮助 mongod help/mongod -h 查看版本 mongod --version 启动/停止/重启服务 net start/stop/restart ...
- spring_boot 加入 mybatis
第一步: <!-- mybatis启动器 自动包含jdbc所以不需要再次引入jdbc依赖 --> <dependency> <groupId>org.mybatis ...
- php设计模式之责任链模式实现举报功能实例代码
html <html> <head> <meta charset="UTF-8"> <title>责任链模式</title&g ...
- angular项目实现mqtt的订阅与发布 ngx-mqtt
angular项目实现mqtt的订阅与发布 如果要写一个exe可执行文件,可以使用angular编写,然后使用electron打包成一个exe文件. https://github.com/maxime ...
- 浅谈ABB机器人(工具坐标,工件坐标,有效载荷)
工具坐标(tool): 使tcl坐标偏移到工具上,例如焊接工作,使机器人工作点切入焊枪点上 mass:工具的重量 xyz:偏移距离的大小 验证:通过手动模式,切换至自定义工具,重定向 工件坐标(wob ...
- hadoop学习笔记(十):hdfs在命令行的基本操作命令(包括文件的上传和下载和hdfs中的文件的查看等)
hdfs命令行 ()查看帮助 hdfs dfs -help ()查看当前目录信息 hdfs dfs -ls / ()上传文件 hdfs dfs -put /本地路径 /hdfs路径 ()剪切文件 hd ...
- gnuplot 让您的数据可视化
https://www.ibm.com/developerworks/cn/linux/l-gnuplot/index.html http://blog.sciencenet.cn/blog-3733 ...
- Python出现Could not find a version that satisfies the requirement openpyxl (from versions: )
一.环境使用python3.7时,用pip安装openpyxl出现如下错误: 系统环境:windows10家庭版Python版本:python3.7.1IDE:sublime_text 3二. 解决方 ...