Submission #345629

# Submission time Handle Problem Language Result Execution time Memory
345629 2021-01-07T17:11:21 Z limabeans Datum (COCI20_datum) C++17
0 / 50
1000 ms 492 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl








vector<int> M = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};



struct date {
    int month, day, year;
    date(string s) {
	int n = s.length();
	vector<int> tmp(3);
	int ptr = 0;
	for (int i=0; i<n; ) {
	    int j=i;
	    while (j<n && s[j]!='.') j++;
	    int cur = 0;
	    while (i<j) {
		cur *= 10;
		cur += int(s[i]-'0');
		i++;
	    }
	    i++;
	    tmp[ptr++] = cur;
	}

	month = tmp[0];
	day = tmp[1];
	year = tmp[2];
	//cout<<month<<" "<<day<<" "<<year<<endl;
    }


    void inc() {
	day++;
	if ((year%4==0 && month==2 && day>29) || day > M[month]) {
	    day = 1;
	    month++;
	    if (month > 12) {
		month = 1;
		year++;
	    }
	}
    }


    bool ispal() {
	string m = to_string(month);
	string d = to_string(day);
	string y = to_string(year);
	while ((int)m.length() < 2) m = "0"+m;
	while ((int)d.length() < 2) d = "0"+d;
	while ((int)y.length() < 4) y = "0"+y;

	string cur = m+d+y;
	int len = cur.length();
	for (int i=0; i<len/2; i++) {
	    if (cur[i]!=cur[len-i-1]) return false;
	}
	return true;
    }


    string tostr() {
	string m = to_string(month);
	string d = to_string(day);
	string y = to_string(year);
	while ((int)m.length() < 2) m = "0"+m;
	while ((int)d.length() < 2) d = "0"+d;
	while ((int)y.length() < 4) y = "0"+y;

	string cur = m+"."+d+"."+y+".";

	return cur;
    }
};



string solve() {
    string s;
    cin>>s;
    date cur(s);
    cur.inc();
    while (!cur.ispal()) {
	cur.inc();
    }

    return cur.tostr();
}



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    int n;
    cin>>n;
    while (n--) {
	cout<<solve()<<"\n";
    }
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 384 KB Output isn't correct
2 Execution timed out 1077 ms 364 KB Time limit exceeded
3 Incorrect 9 ms 364 KB Output isn't correct
4 Incorrect 41 ms 364 KB Output isn't correct
5 Incorrect 7 ms 364 KB Output isn't correct
6 Incorrect 540 ms 364 KB Output isn't correct
7 Incorrect 682 ms 392 KB Output isn't correct
8 Incorrect 566 ms 364 KB Output isn't correct
9 Incorrect 368 ms 492 KB Output isn't correct
10 Execution timed out 1089 ms 364 KB Time limit exceeded