# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238827 | Exile_2k4 | Datum (COCI20_datum) | C++17 | 11 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
#define year tuple<int,int,int>
signed main(){
// freopen("datum.inp","r",stdin);
// freopen("datum.out","w",stdout);
int n;
scanf("%d",&n);
set<year> s;
for(int mm=1;mm<=12;++mm){
for(int dd=1;dd<=days[mm];++dd){
string d,m;
if(dd<10) d+="0";
if(mm<10) m+="0";
d+=to_string(dd),m+=to_string(mm);
string yy = d+m;
reverse(begin(yy),end(yy));
if(dd==29 && stoi(yy)%4) continue;
s.insert({stoi(yy),mm,dd});
}
}
for(int i=0;i<n;++i){
int d,m,y;
scanf("%d.%d.%d.",&d,&m,&y);
auto pick = s.lower_bound({y,m,d});
if(make_tuple(y,m,d)==*pick) pick = next(pick);
auto ans = *pick;
printf("%02d.%02d.%04d.\n",get<2>(ans),get<1>(ans),get<0>(ans));
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |