板子判断 + set排序+去重
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
struct Ac {
bool isSb(int y, int m, int d) {
if (y >= 60)
y += 1900;
else
y += 2000;
if (y < 1960 || y > 2059 || m > 12 || m <= 0 || d <= 0)
return false;
if (m == 2 || m == 4 || m == 6 || m == 9 || m == 11) {
if (d > 30)
return false;
if (m == 2) {
if (y % 400 == 0 || (y % 100 && y % 4 == 0))
return d <= 29;
return d <= 28;
}
}
return true;
}
void run() {
// 日月年 abc
// 年月日 cba
// 年日月 cab
int a, b, c;
scanf("%d/%d/%d", &a, &b, &c);
set<tuple<int, int, int>> res;
if (isSb(a, b, c))
res.insert(tuple<int, int, int>{a, b, c});
if (isSb(c, a, b))
res.insert(tuple<int, int, int>{c, a, b});
if (isSb(c, b, a))
res.insert(tuple<int, int, int>{c, b, a});
for (auto it : res) {
int y, m ,d;
tie(y, m, d) = it;
if (y >= 60)
y += 1900;
else
y += 2000;
printf("%d-%02d-%02d\n", y, m, d);
}
}
};
int main() {
Ac ak;
ak.run();
return 0;
}
0 回复
0 转发
1 喜欢
4 阅读



