#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;
ll mod_(ll a, ll b)
{
if(a >= 0)return a % b;
a += (-a/b + 1) * b;
return a % b;
}
ll to_int(string s) // TEST THIS
{
ll 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 + ".";
}
ll mon[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
bool check(string day, string mo, string ye)
{
ll 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<ll>s;
void solve()
{
for(ll i = 0; i <= 9999; ++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());
while(d.size() < 2)d = "0" + d;
while(m.size() < 2)m = "0" + m;
while(y.size() < 4)y = "0" + y;
if(check(d, m, y))
{
s.insert(to_int(d + "." + m + "." + y + "."));
}
}
ll n;
cin >> n;
while(n--)
{
string a;
cin >> a;
ll ans = *s.upper_bound(to_int(a));
cout << int_to_str(ans) << endl;
}
}
int main()
{
fio;
//ll t; cin >> t; while(t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |