# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845098 |
2023-09-06T11:56:46 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
37 ms |
536 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int int64_t
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
#define F first
#define S second
#define PB push_back
#define POB pop_back
#define sqr(a) ((a) * (a))
#define P pop
#define max3(a, b, c) (max(a, max(b, c)))
#define max4(a, b, c, d) (max(max(a, b), max(c, d)))
#define min3(a, b, c) (min(a, min(b, c)))
#define min4(a, b, c, d) (min(min(a, b), min(c, d)))
#define MOD 1000000007
#define mod 998244353
int binpow(int a, int p, int m = MOD) {
int ans = 1;
while (p) {
if (p & 1) ans = ((ans % m) * (a % m)) % m;
a = sqr(a) % m;
p >>= 1;
}
return ans;
}
map<int, int> mont;
int d, m;
bool isvalid(int y) {
d = y % 100;
d = (d % 10) * 10 + d / 10;
m = y / 100;
m = (m % 10) * 10 + m / 10;
if (m > 12) return false;
if ((m == 2 && y % 4 == 0 && d <= 29) || d <= mont[m]) {
return true;
}
return false;
}
void solve() {
string s;
cin >> s;
int y = stoi(string({s[6], s[7], s[8], s[9]}));
int ms = stoi(string({s[3], s[4]}));
int ds = stoi(string({s[0], s[1]}));
for (int i = y; i <= 9999; i++) {
if (isvalid(i) &&
!((m < ms && y == i) || (d <= ds && m == ms && y == i))) {
string D = to_string(d);
if (D.size() == 1) D = "0" + D;
string M = to_string(m);
if (M.size() == 1) M = "0" + M;
string I = to_string(i);
if (I.size() != 4) I = string(4 - I.size(), '0') + I;
string ans = D + "." + M + "." + I + ".";
cout << ans << endl;
return;
}
}
}
int32_t main() {
int t = 1;
cin >> t;
mont[1] = 31;
mont[2] = 28;
mont[3] = 31;
mont[4] = 30;
mont[5] = 31;
mont[6] = 30;
mont[7] = 31;
mont[8] = 31;
mont[9] = 30;
mont[10] = 31;
mont[11] = 30;
mont[12] = 31;
while (t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
37 ms |
536 KB |
Output isn't correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
34 ms |
344 KB |
Output isn't correct |