# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219338 | VEGAnn | Datum (COCI20_datum) | C++14 | 515 ms | 57876 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>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define PB push_back
using namespace std;
const int N = 4000100;
const int oo = 2e9;
string s, t;
vector<array<int, 3> > vc;
int moths[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int nearest[N];
string tostr(int x, int len){
string res = "";
for (int it = 0; it < len; it++){
res += char(x % 10 + '0');
x /= 10;
}
reverse(all(res));
return res;
}
bool pali(int id){
s = "";
s += tostr(vc[id][2], 2);
s += tostr(vc[id][1], 2);
s += tostr(vc[id][0], 4);
t = s;
reverse(all(t));
return (s == t);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
for (int year = 1; year < 10000; year++)
for (int mon = 0; mon < 12; mon++){
int kol_days = moths[mon];
if (year % 4 == 0 && mon == 1)
kol_days++;
for (int days = 1; days <= kol_days; days++)
vc.PB({year, mon + 1, days});
}
nearest[sz(vc) - 1] = sz(vc);
for (int i = sz(vc) - 2; i >= 0; i--)
if (pali(i + 1))
nearest[i] = i + 1;
else nearest[i] = nearest[i + 1];
int qq; cin >> qq;
for (; qq; qq--){
int d = 0, m = 0, y = 0;
char c;
cin >> c; d = d * 10 + (c - '0');
cin >> c; d = d * 10 + (c - '0');
cin >> c;
cin >> c; m = m * 10 + (c - '0');
cin >> c; m = m * 10 + (c - '0');
cin >> c;
cin >> c; y = y * 10 + (c - '0');
cin >> c; y = y * 10 + (c - '0');
cin >> c; y = y * 10 + (c - '0');
cin >> c; y = y * 10 + (c - '0');
cin >> c;
array<int, 3> ar = {y, m, d};
int loc = lower_bound(all(vc), ar) - vc.begin();
int id = nearest[loc];
cout << tostr(vc[id][2], 2) << "." << tostr(vc[id][1], 2) << "." << tostr(vc[id][0], 4) << ".\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |