传送门
今日水题呜呜呜
这题注意读题和考虑边界条件, 边界条件非常严苛
第三个点,必须判断是在0-9 a-n直接同时cnt=1的条件, 不过这属于代码数写方式的特例, 不同代码可能不会遇到这样的, 其他的点的问题可以看别的博主, 我这里就不赘述了
#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ":" << a <<endl
#define For(i,x,y) for(int i=(x); i<=(y); ++i)
const int MAX = 2e5+7;
using namespace std;
int n,m;
int arr[MAX];
string day[8] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
int main(void) {
string str[4];
for(int i=0; i<4; i++){
cin >>str[i];
// debug(str[i]);
}
int cnt=0;
int len0 = str[0].length(),len1 = str[1].length(),len2 = str[2].length(),len3 = str[3].length();
int firstTwo = len0 > len1 ? len1: len0;
int lastTwo = len2 > len3 ? len3: len2;
int d,h,m=0;
for(int i=0; i<firstTwo; i++){
//debug(i);
if(str[0][i]==str[1][i]) {
if(cnt==0&&(str[0][i] >= 'A' && str[0][i]<='G')) {//abcdefg
cnt++;
d = str[0][i]-'A';
} else if( cnt==1&&((str[0][i] >= 'A' && str[0][i]<='N')||(isdigit(str[0][i])))) { // 注意从这里开始,如果替换为文末的代码是不能过的
if(str[0][i] >= 'A' && str[0][i]<='N') h = str[0][i]-'A'+10;
else if(isdigit(str[0][i])) h = str[0][i]-'0';
cnt++;
break;
}
//debug(cnt);
}
}
for(int i=0; i<lastTwo; i++){
//debug(i);
if(str[2][i]==str[3][i]&&isalpha(str[2][i])) {
//debug(cnt);
if(cnt==2) {
m = i;
break;
}
}
}
cout << day[d];
printf(" %02d:%02d",h,m);
return 0;
}
} else if( cnt==1) {
if(str[0][i] >= 'A' && str[0][i]<='N') h = str[0][i]-'A'+10;
else if(isdigit(str[0][i])) h = str[0][i]-'0';
break;
}
//debug(cnt);
}
}
for(int i=0; i<lastTwo; i++){
//debug(i);
if(str[2][i]==str[3][i]&&isalpha(str[2][i])) {
cnt++;
//debug(cnt);
if(cnt==2) {
m = i;
break;
}
}
}
cout << day[d];
printf(" %02d:%02d",h,m);
return 0;
}