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
字符串的处理,第一个与第二个字符串第一个位置相同的字母(ABCDEFG)中的一个代表星期,第一个与第二个字符串位置上相同的字符(0-9或A-N)代表的是0-23h,第三个与第四个字符串上位置相同的英文字母(a-z以及A-Z)的位置从0开始代表的是分钟数
满分代码如下:
#include<bits/stdc++.h>
using namespace std;
map<int,string>mp={{1,"MON"},{2,"TUE"},{3,"WED"},
{4,"THU"},{5,"FRI"},{6,"SAT"},
{7,"SUN"}};
int main(){
string a,b,c,d;
cin>>a>>b>>c>>d;
int k1,k2,k3,j;
for(int i=0;i<a.size();i++){
if(!isupper(a[i])) continue;
if(a[i]>'G') continue;
if(b[i]!=a[i]) continue;
j=i;
break;
}
k1=a[j]-'A'+1;
for(int i=j+1;i<a.size();i++){
if(!isupper(a[i])&&!isdigit(a[i])) continue;
if(a[i]>'N') continue;
if(b[i]!=a[i]) continue;
if(isdigit(a[i])){
k2=a[i]-'0';
break;
}else{
k2=a[i]-'A'+1+9;
break;
}
}
for(int i=0;i<c.size();i++){
if(!isalpha(c[i])) continue;
if(d[i]!=c[i]) continue;
k3=i;
break;
}
printf("%s %02d:%02d\n",mp[k1].c_str(),k2,k3);
return 0;
}