【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 ...
随机推荐
- IIS支持json、geojson文件
最近在搞asp.net + openlayers. 其中openlayer有个数据源支持 .geojson 数据,但是怎么测试都不能成功.同样的数据拿到php下就能成功显示. 搓. 在网上漫无目的的搜 ...
- valign
值 描述 top 对内容进行上对齐. middle 对内容进行居中对齐(默认值). bottom 对内容进行下对齐. baseline 与基线对齐.
- Java必须知道的知识点
junit用法,before,beforeClass,after, afterClass的执行顺序 分布式锁 nginx的请求转发算法,如何配置根据权重转发 用hashmap实现redis有什么问题( ...
- war文件—Web项目部署
war文件是什么? Web存档(war)文件包含Web应用程序的所有内容.它减少了传输文件所需要的时间. war文件的优点 节省时间:war文件将所有文件合并为一个单位. 所以在将文件从客户端传输到 ...
- 正则表达式过滤url请求
过滤url中带reset的url请求 atgBusSignFilter.setSignUriRegex("^.*/reset/.*$")等价于 atgBusSignFilter.s ...
- CF432D Prefixes and Suffixes
CF432D Prefixes and Suffixes 题意 给你一个长度为n的长字符串,"完美子串"既是它的前缀也是它的后缀,求"完美子串"的个数且统计这些 ...
- Bayer Pattern
在刚加入工作的时候,听到最多的就是RGGB Bayer Pattern.在之前的接触中,一直默认一张图片的每个像素点有RGB三个分量,那“RGGB Bayer Pattern”究竟是什么意思.在网上查 ...
- IIS虚拟目录
https://blog.csdn.net/mianyao1004/article/details/94036169
- 通过JMX获取JVM信息
package com.googosoft.gateway_zuul; import java.lang.management.ClassLoadingMXBean; import java.lang ...
- mac VirtualBox虚拟机装CentOS,并配置网络,使其发布的静态网站能访问
1.下载VirtualBox(macOS版本) 下载地址:https://download.virtualbox.org/virtualbox/6.0.8/VirtualBox-6.0.8-13052 ...