# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845068 | vjudge1 | Datum (COCI20_datum) | C++17 | 3 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.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 3e5 + 5;
vector<int> months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<int> possible;
bool check(int day, int month) {
if (month == 0 || day == 0 || month > 12)
return false;
int mx = months[month-1];
if (day <= mx)
return true;
return false;
}
int main() {
fast
int N;
cin >> N;
for (int i = 1; i <= 9999; i++) {
int plc0 = (i / 1000) % 10;
int plc1 = (i / 100) % 10;
int plc2 = (i / 10) % 10;
int plc3 = i % 10;
if (check(plc3 * 10 + plc2, plc1 * 10 + plc0))
possible.push_back(i);
}
for (int i = 0; i < N; i++) {
string s;
cin >> s;
int year = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
int Q = upper_bound(possible.begin(), possible.end(), year) - possible.begin();
int need_year = possible[Q];
string ans = "";
ans = ans + char('0' + need_year % 10);
need_year/=10;
ans = ans + char('0' + need_year % 10);
need_year/=10;
ans = ans + '.';
ans = ans + char('0' + need_year % 10);
need_year/=10;
ans = ans + char('0' + need_year % 10);
need_year/=10;
ans = ans + '.';
need_year = possible[Q];
int plc0 = need_year / 1000;
int plc1 = (need_year / 100) % 10;
int plc2 = (need_year / 10) % 10;
int plc3 = need_year % 10;
ans = ans + char('0' + plc0) + char('0' + plc1) + char('0' + plc2) + char('0' + plc3) + '.';
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |