| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 845109 | vjudge1 | Datum (COCI20_datum) | C++17 | 5 ms | 348 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.
// author: erray
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.h"
#else
  #define debug(...) void(37)
#endif
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int TT;
  cin >> TT;
  while (TT--) {
    string D;
    cin >> D;
    int cur = 0, year = 0;
    auto C = [&](char c) {
      return c - '0';
    };
    cur = C(D[0]) + 10 * C(D[1]) + 100 * C(D[3]) + 1000 * C(D[4]);
    for (int i = 0, pw = 1; i < 4; ++i, pw *= 10) {
      year += pw * C(D.end()[-i - 2]);
    }
    debug(cur, year); 
    auto Find = [&](int y) {
      auto Day = [&](int x) {
        int r = x % 100;
        return r % 10 * 10 + (r / 10);
      };
      auto Month = [&](int x) {
        int r = x / 100;
        return r % 10 * 10 + (r / 10);
      };
      auto Leap = [&](int x) {
        return x % 4 == 0;
      };
      constexpr int days[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
      auto Valid = [&](int x) {
        int m = Month(x);
        return m <= 12 && m > 0 && (days[m] - (m == 2 && Leap(x)) >= Day(x)); 
      };
      debug("here");
      for (int add = 0; add < 100; ++add) {
        if (Valid(y + add)) {
          return y + add;
        }
      }
      debug("bad");
      y -= y % 100;
      y += 1;
      while (Month(y) > 12 || Month(y) == 0) {
        y += 100;  
      }
      debug(y);
      assert(Valid(y));
      return y;
      //divisible by 4 but not 100
    };
    int ans = Find(year);
    if (ans == year && cur >= year) {
      ans = Find(year + 1);
    }
    debug(ans);
    string res;
    string yts = to_string(ans);
    while (yts.size() < 4) {
      yts.insert(yts.begin(), '0');
    }
    debug(yts);
    res += yts;
    reverse(res.begin(), res.end());
    res += yts;
    res.insert(res.begin() + 2, '.');
    res.insert(res.begin() + 5, '.');
    res.insert(res.end(), '.');
    cout << res << '\n';
  }  
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
