# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238613 | SamAnd | Datum (COCI20_datum) | C++17 | 793 ms | 504 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 m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
int q[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
struct ban
{
int y, m, d;
ban(){}
ban(int y, int m, int d)
{
this->y = y;
this->m = m;
this->d = d;
}
};
bool operator<(const ban& a, const ban& b)
{
if (a.y < b.y)
return true;
if (a.y > b.y)
return false;
if (a.m < b.m)
return true;
if (a.m > b.m)
return false;
return a.d < b.d;
}
vector<ban> u;
void pre()
{
for (int y = 0; y <= 9999; ++y)
{
if (y % 4 == 0)
q[1] = 29;
for (int m = 1; m <= 12; ++m)
{
for (int d = 1; d <= q[m - 1]; ++d)
{
vector<int> v;
int x = y;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 4)
v.push_back(0);
x = m;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 6)
v.push_back(0);
x = d;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 8)
v.push_back(0);
reverse(all(v));
bool z = true;
for (int i = 0; i < 8; ++i)
{
if (v[i] != v[8 - i - 1])
{
z = false;
break;
}
}
if (z)
{
u.push_back(ban(y, m, d));
}
}
}
q[1] = 28;
}
}
void solv()
{
int qq;
scanf("%d", &qq);
while (qq--)
{
char a[20];
scanf(" %s", a);
int y = 0, d = 0, m = 0;
for (int i = 6; i < 6 + 4; ++i)
{
y = y * 10 + a[i] - '0';
}
for (int i = 3; i < 3 + 2; ++i)
{
m = m * 10 + a[i] - '0';
}
for (int i = 0; i < 0 + 2; ++i)
{
d = d * 10 + a[i] - '0';
}
ban ans = *upper_bound(all(u), ban(y, m, d));
y = ans.y;
d = ans.d;
m = ans.m;
vector<int> v;
int x = y;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 4)
v.push_back(0);
x = m;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 6)
v.push_back(0);
x = d;
while (x)
{
v.push_back(x % 10);
x /= 10;
}
while (v.size() < 8)
v.push_back(0);
reverse(all(v));
printf("%d%d.%d%d.%d%d%d%d.\n", v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
}
}
int main()
{
#ifdef SOMETHING
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif // SOMETHING
//ios_base::sync_with_stdio(false), cin.tie(0);
pre();
solv();
return 0;
}
//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |