PTA 福尔摩斯的约会 (20分)

    科技2025-07-07  15

    每个人都有崩溃的时候,就看你的抗压能力到底有多强,如果你的抗压能力强,有办法可以支撑到你能面对并且解决这些困难的话,你就没有问题。                                                                          ----喻言

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D,代表星期四;第 2 对相同的字符是 E ,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 23 点由数字 0 到 9、以及大写字母 A 到 N 表示);后面两字符串第 1 对相同的英文字母 s 出现在第 4 个位置(从 0 开始计数)上,代表第 4 分钟。现给定两对字符串,请帮助福尔摩斯解码得到约会的时间。

    输入格式:

    输入在 4 行中分别给出 4 个非空、不包含空格、且长度不超过 60 的字符串。

    输出格式:

    在一行中输出约会的时间,格式为 DAY HH:MM,其中 DAY 是某星期的 3 字符缩写,即 MON 表示星期一,TUE 表示星期二,WED 表示星期三,THU 表示星期四,FRI 表示星期五,SAT 表示星期六,SUN 表示星期日。题目输入保证每个测试存在唯一解。

    输入样例:

    3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm

    输出样例:

    THU 14:04 #include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cstring> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <vector> #include <ctime> #include <cctype> #include <bitset> #include <utility> #include <sstream> #include <complex> #include <iomanip> #include <numeric> #include<unordered_set> #include <climits>//INT_maxnn //#include<bits/stdc++.h> #define PP pair<ll,int> #define inf 0x3f3f3f3f #define INF 0x7fffffff; #define llinf 0x3f3f3f3f3f3f3f3fll #define dinf 1000000000000.0 #define PI 3.1415926 #define LL unsigned int #define wc 1e-8 typedef long long ll; using namespace std; string s[]= {"","MON","TUE","WED","THU","FRI","SAT","SUN"}; string s1,s2,s3,s4; int main() { cin>>s1>>s2>>s3>>s4; int fg=0; int ct=min(s1.length(),s2.length()); for(int i=0; i<ct; i++) { if(!fg) { if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G') { cout<<s[s1[i]-'A'+1]<<" "; fg=1; } } else { if(s1[i]==s2[i]) { if(isdigit(s1[i])) { printf("%02d",s1[i]-'0'); break; } else if(s1[i]>='A'&&s1[i]<='N') { printf("%02d",s1[i]-'A'+10); break; } } } } cout<<":"; int tt=min(s3.length(),s4.length()); for(int i=0; i<tt; i++) { if(isalpha(s3[i])) { if(s3[i]==s4[i]) printf("%02d",i); } } return 0; }

     

    Processed: 0.010, SQL: 8