Submission #845072

# Submission time Handle Problem Language Result Execution time Memory
845072 2023-09-06T11:50:19 Z vjudge1 Datum (COCI20_datum) C++17
40 / 50
1000 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  auto tos = [&](int day, int month, int year) {
    string a = to_string(day);
    string b = to_string(month);
    string c = to_string(year);
    while (a.size() != 2) {
      a.insert(a.begin(), '0');
    }
    while (b.size() != 2) {
      b.insert(b.begin(), '0');
    }
    while (c.size() != 4) {
      c.insert(c.begin(), '0');
    }
    return a + b + c;
  };
  auto pal = [&](int day, int month, int year) {
    string d = tos(day, month, year); 
    string e = d;
    reverse(e.begin(), e.end());
    return d == e;
  };
  vector<int> last = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  auto max_day = [&](int m, int year) {
    return last[m-1] + (m == 2 && year % 4 == 0);
  };
  while (t--) {
    string date;
    cin >> date;
    int day = (date[0]-'0')*10 + (date[1]-'0');
    int month = (date[3]-'0')*10 + (date[4]-'0');
    int year = (date[6]-'0')*1000 + (date[7]-'0')*100 + (date[8]-'0') * 10 + (date[9]-'0');
    do {
      day += 1;
      if (day > max_day(month, year)) {
        month += 1;
        day = 1;
      }
      if (month > 12) {
        year += 1;
        month = 1;
      }
    } while(!pal(day, month, year)); 
    string ans = tos(day, month, year);
    ans.insert(ans.begin()+2, '.');
    ans.insert(ans.begin()+5, '.');
    ans.push_back('.');
    cout << ans << '\n';
  } 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 1030 ms 344 KB Time limit exceeded
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 86 ms 600 KB Output is correct
7 Correct 100 ms 344 KB Output is correct
8 Correct 115 ms 440 KB Output is correct
9 Correct 110 ms 344 KB Output is correct
10 Execution timed out 1046 ms 344 KB Time limit exceeded