# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
373057 | Nimbostratus | Datum (COCI20_datum) | C++14 | 32 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define cln(a,s) memset((a),0,sizeof((a)[0])*(s))
#define all(x) (x).begin() , (x).end()
#define fi first
#define se second
#define int int
using pii = pair<int,int>;
using ll = long long;
const int maxn = 2e5 + 5;
const int inf = 1e9;
const int mod = 1e9+7;
class date {
public:
string sday,smonth,syear;
int day,month,year;
date() {
day = inf;
month = inf;
year = inf;
}
date(string& sd,string& sm,string& sy) {
day = stoi(sd);
month = stoi(sm);
year = stoi(sy);
sday = sd;
smonth = sm;
syear = sy;
}
friend bool operator < (date& x , date& y) {
if(x.year < y.year) return true;
if(x.year > y.year) return false;
if(x.month < y.month) return true;
if(x.month > y.month) return false;
return x.day < y.day;
}
friend bool operator == (date& x , date& y) {
return x.year == y.year and x.month == y.month and x.day == y.day;
}
friend bool operator <= (date& x , date& y) {
return x < y or x == y;
}
};
int n;
string s;
vector<date> vec;
vector<int> days;
bool isvalid(date& x) {
if(x.month == 2 && x.day == 29) return x.year % 4 == 0;
if(x.month > 12 or x.month <= 0) return false;
if(x.day > days[x.month] or x.day <= 0) return false;
return true;
}
date datify() {
string day,month,year;
int i=0;
for(;i<s.size() && s[i] != '.';i++)
day += s[i];
i++;
for(;i<s.size() && s[i] != '.';i++)
month += s[i];
i++;
for(;i<s.size() && s[i] != '.';i++)
year += s[i];
return date(day,month,year);
}
int32_t main () {
//freopen("in","r",stdin); freopen("out","w",stdout);
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
days = {0,31,28,31,30,31,30,31,31,30,31,30,31};
for(char i='0';i<='3';i++)
for(char j='0';j<='9';j++)
for(char k='0';k<='1';k++)
for(char m='0';m<='9';m++) {
string day = string()+i+j;
string month = string()+k+m;
string year = day + month;
reverse(all(year));
date d(day,month,year);
if(isvalid(d)) {
vec.pb(d);
}
}
sort(all(vec));
/*for(date x : vec) {
cout << x.day << "." << x.month << "." << x.year << "." << endl;
}*/
//cout << endl;
cin >> n;
while(n--) {
cin >> s;
date x = datify();
int i;
for(i=0;i<vec.size() and vec[i]<=x;i++);
date d = vec[i];
cout << d.sday << "." << d.smonth << "." << d.syear << "." << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |