1061. Dating (20)
时间限制
100 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
第一个相同的A到G的是星期几,第二个相同的在A到N和0到9的是小时
相同的字母的位置是几分
#include<cmath>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;
int n, day = -1, hour = -1, minute = -1;
char a[maxn], b[maxn];
char name[7][10] = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
int main()
{
scanf("%s%s", a, b);
for (int i = 0; a[i] && b[i]; i++)
if (a[i] == b[i])
{
if (day == -1 && a[i] >= 'A'&&a[i] <= 'G') day = a[i] - 'A';
else if (day >= 0)
{
if (a[i] >= 'A'&&a[i] <= 'N'){ hour = a[i] - 'A' + 10; break; }
else if (a[i] >= '0'&&a[i] <= '9'){ hour = a[i] - '0'; break; }
}
}
scanf("%s%s", a, b);
for (int i = 0; a[i] && b[i]; i++)
{
if (a[i] == b[i] && (a[i] >= 'a'&&a[i] <= 'z' || a[i] >= 'A'&&a[i] <= 'Z')) minute = i;
}
printf("%s %02d:%02d\n", name[day], hour, minute);
return 0;
}