# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845307 | vjudge1 | Datum (COCI20_datum) | C++17 | 227 ms | 612 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;
bool check(string _year){
int day = (_year[3]-'0')*10+(_year[2]-'0');
int month = (_year[1]-'0')*10+(_year[0]-'0');
int year = _year[0]*1000+_year[1]*100+_year[2]*10+_year[3];
if (month<=0 || month>=13) return false;
int ma = 31;
if (month==4) ma = 30;
if (month==6) ma = 30;
if (month==9) ma = 30;
if (month==11) ma = 30;
if (month==2){
ma=28;
if (year%4==0) ma=29;
}
if (day<=0 || day>ma) return false;
return true;
}
string make(int num){
string year = to_string(num);
string ret = "";
ret.push_back(year[3]);
ret.push_back(year[2]);
ret.push_back('.');
ret.push_back(year[1]);
ret.push_back(year[0]);
ret.push_back('.');
ret.push_back(year[0]);
ret.push_back(year[1]);
ret.push_back(year[2]);
ret.push_back(year[3]);
ret.push_back('.');
return ret;
}
string getmonth(string date){
return date.substr(3,2);
}
string getyear(string date){
return date.substr(6,4);
}
string getday(string date){
return date.substr(0,2);
}
int32_t main(){
int n;cin>>n;
while (n--){
string str;cin>>str;
int cry = (str[6]-'0')*1000+(str[7]-'0')*100+(str[8]-'0')*10+(str[9]-'0');
string hehe = make(cry);
while (!check(to_string(cry)) || getyear(hehe)<getyear(str) || (getyear(hehe)==getyear(str) && getmonth(hehe)<getmonth(str)) || (getyear(hehe)==getyear(str) && getmonth(hehe)==getmonth(str) && getday(hehe)<=getday(str))){
cry++;
hehe=make(cry);
}
cout<<make(cry)<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |