1061. Dating (20)
2016-02-22 20:06
302 查看
1061. Dating (20)
时间限制50 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since
the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours
from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings,
you are supposed to help Sherlock decode the dating time.
Input Specification:
Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.
Output Specification:
For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT"
for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.
Sample Input:
3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
Sample Output:
THU 14:04
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
using namespace std;
int main() {
string p1,p2,str1,str2,weeks[7]= {"MON","TUE","WED","THU","FRI","SAT","SUN"};
cin>>p1>>p2>>str1>>str2;
int week=0,hour=0,minute=0,count1=0,count2=0;
int len = p1.size()<p2.size()?p1.size():p2.size();
for(int i=0; i<len; i++) {
if(p1[i]==p2[i]) {
bool f = 'A'<=p1[i]&&p1[i]<='N'||'0'<=p1[i]&&p1[i]<='9';
if(count1==1&&f)
count2++;
if('A'<=p1[i]&&p1[i]<='G'&&count1==0) {
count2++;
count1++;
week = i;
}
if(count2==2) {
hour = i;
}
if(count2==2&&count1==1)
break;
}
}
len = str1.size()<str2.size()?str1.size():str2.size();
for(int i=0; i<len; i++) {
bool a = 'a'<=str1[i]&&str1[i]<='z'||'A'<=str1[i]&&str1[i]<='Z';
if(str1[i]==str2[i]&&a) {
minute = i;
break;
}
}
bool res='A'<=p2[hour]&&p2[hour]<='Z';
hour = res?p2[hour]-'A'+10:p2[hour]-'0';
printf("%s %02d:%02d\n",weeks[p1[week]-'A'].c_str(),hour,minute);
return 0;
}
相关文章推荐
- HDU-1856 More is better
- java.lang.ClassNotFoundException: org.apache.commons.collections.FastHashMap的解决方法
- MTK MAINAF-->2-000c
- PTA-- 快速排序(25)
- HTML标记之Form表单
- yii学习历程1——归档文件安装
- 左值和右值
- PTA--魔法优惠券——stl快速排序
- AsyncTask源码解析
- javascript 复习代码
- “瀑布流式”图片懒加载代码解析及优化(二)
- 禁止网站页面内容被复制的javascript代码,在公共js文件中写入下图中代码(兼容forefox和IE)
- 搭建Storm集群
- PAT--朋友圈--并查集
- “瀑布流式”图片懒加载代码解析及优化(二)
- QToolBar也是QWidget,可以放在QWidget的中间
- android_demo01
- css定高块级元素垂直居中
- 第0周周赛——极限手速赛(题解)之上篇
- PAT--公路村村通--最小生成树--Kruskal算法