# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845356 |
2023-09-06T13:16:46 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
6 ms |
348 KB |
#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;
}
int 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(int 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 <= 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());
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 |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Incorrect |
6 ms |
344 KB |
Output isn't correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |