1084. Broken Keyboard (20)
2015-08-01 14:15
375 查看
Sample Output:1084. Broken Keyboard (20)
时间限制200 ms 内存限制65536 kB 代码长度限制16000 B 判题程序Standard作者CHEN, Yue On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.Input Specification:Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or "_" (representing the space). It is guaranteed that both strings are non-empty.Output Specification:For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.Sample Input:7_This_is_a_test _hs_s_a_es
7TI在typeOut长度范围内 original和打出的typeOut一样 两者都加, 否则typeOut缺失看看这个缺失的在不再brokenkeys里面,不在加;在typeOut长度范围外 看看剩下的original是否有不在brokenkeys里面的,不在加
评测结果
时间 | 结果 | 得分 | 题目 | 语言 | 用时(ms) | 内存(kB) | 用户 |
---|---|---|---|---|---|---|---|
8月01日 14:07 | 答案正确 | 20 | 1084 | C++ (g++ 4.7.2) | 1 | 436 | datrilla |
测试点
测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
---|---|---|---|---|
0 | 答案正确 | 1 | 384 | 12/12 |
1 | 答案正确 | 1 | 436 | 3/3 |
2 | 答案正确 | 1 | 304 | 1/1 |
3 | 答案正确 | 1 | 304 | 1/1 |
4 | 答案正确 | 1 | 308 | 3/3 |
#include<iostream> #include<string> using namespace std; bool TheSame(char A, char B) { if (A == B || A >= 'a'&&A <= 'z'&&A - 'a' + 'A' == B) return true; return false; } char AddTheBag(char c) { if (c >= 'a'&&c <= 'z')return c - 'a' + 'A'; return c; } bool NoInbrokeys(string brokenkeys, char ctemp,int lenb) { int index; for (index = 0; index < lenb; index++) { if (brokenkeys[index] == ctemp || ctemp >= 'a'&&ctemp <= 'z'&&ctemp - 'a' + 'A' == brokenkeys[index]) return false; } return true; } int main() { string original, brokenkeys,typeOut; int oindex, tindex, leno,lent,lenb; cin >> original >> typeOut; leno = original.size(); lent = typeOut.size(); lenb = brokenkeys.size(); for (oindex = 0,tindex=0; oindex < leno; oindex++) { if (tindex < lent) { if (TheSame(original[oindex], typeOut[tindex])) { tindex++; } else if (NoInbrokeys(brokenkeys, original[oindex], lenb)) { brokenkeys += AddTheBag(original[oindex]); lenb++; } } else if (NoInbrokeys(brokenkeys, original[oindex], lenb)) { brokenkeys += AddTheBag(original[oindex]); lenb++; } } cout << brokenkeys << endl; system("pause"); return 0; }
相关文章推荐
- Win7系统中文件删不掉怎么办?Win7系统中将删不掉的文件快速解决办法
- 图像遍历
- grep
- C语言:循环单链表的创建,遍历,插入
- 机试算法讲解: 第33题 并查集之找小伙伴
- Add Two Numbers
- 上市公司恋上互联网金融 目前已有14家涌入P2P
- [LeetCode] Valid Anagram
- mqtt的ClientSub
- 三个同步与互斥问题之生产者与消费者
- 机试算法讲解:第34题 并查集之求最短公路总长度
- JavaScript 如何计算2个时间差 工作时间为8小时
- 浅谈对java中的hashset和Treeset 中重写equals()方法的不同及用法
- mqtt的ClientPub
- 什么是MAK激活密钥?win10查看已激活Windows密钥Key的教程
- [python 爬虫学习]利用cookie模拟网站登录
- 2048游戏详解
- 那些低调的美国互联网金融公司
- svn服务器搭建
- java 中 try catch finally 语句的执行顺序