# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845326 | MercubytheFirst | Datum (COCI20_datum) | C++14 | 4 ms | 600 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;
using ll = long long;
using ld = long double;
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define CDIV(a,b) (((a)+(b)-(1))/(b))
const ll inf = 1e17 + 5;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 30;
int mod_(int a, int b)
{
if(a >= 0)return a % b;
a += (-a/b + 1) * b;
return a % b;
}
ll to_int(string s) // TEST THIS
{
int d = stoi(string{s.begin(), s.begin() + 2}),
m = stoi(string{s.begin() + 3, s.begin() + 5}),
y = stoi(string{s.begin() + 6, s.end() - 1});
return (1e4 * y) + (100 * m) + d;
}
string int_to_str(ll x)
{
string d = to_string(x % 100),
m = to_string((x % 10000) / 100),
y = to_string(x / 10000);
while(d.size() < 2)d = "0" + d;
while(m.size() < 2)m = "0" + m;
while(y.size() < 4)y = "0" + y;
return d + "." + m + "." + y + ".";
}
int mon[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
bool check(string day, string mo, string ye)
{
int d = stoi(day), m = stoi(mo), y = stoi(ye);
if(d < 1 or m < 1)return false;
if(m == 2 and d == 29 and y % 4)return false;
if(m > 12)return false;
if(mon[m - 1] < d)return false;
return true;
}
set<int>s;
void solve()
{
for(int i = 0; i < 3000; ++i)
{
string y = to_string(i);
while(y.size() < 4)y = "0" + y;
reverse(y.begin(), y.end());
string d{y.begin(), y.begin() + 2},
m{y.begin() + 2, y.end()};
reverse(y.begin(), y.end());
if(check(d, m, y))
{
s.insert(to_int(d + "." + m + "." + y + "."));
}
}
int n;
cin >> n;
while(n--)
{
string a;
cin >> a;
int ans = *s.upper_bound(to_int(a));
cout << int_to_str(ans) << endl;
}
}
int main()
{
fio;
//int t; cin >> t; while(t--)
{
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |