/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 18;
string pr(int a, int tp){
string res = to_string(a);
if(tp==0 || tp==1) if(res.length() == 2) return res; else return "0"+res;
if(res.length() == 4) return res;
if(res.length() == 3) return "0"+res;
if(res.length() == 2) return "00"+res;
return "000"+res;
}
bool check(array<int, 3>a ){
string s = pr(a[0], 0) + pr(a[1], 1) + pr(a[2], 2);
for(int i = 0; i < s.length()/2; ++i) if(s[i] != s[s.length()-1-i]) return false;
return 1;
}
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
array<int, 3> a;
array<int, 3> dp[11000][35][12];
void solve(){
vector<array<int, 3>> cur;
a[0] = 0, a[1] = 0, a[2] = 0;
cur.pb(a);
for(int i = 0; i < 365*11000; ++i){
if(a[0] < month[a[1] - 1]) a[0]++;
else if(a[0] >= month[a[1] - 1]){
if(a[1] == 12){
a[0] = 1, a[1] = 1;
a[2]++;
}else if(a[1] == 2){
if(a[2] % 4 == 0){
if(a[0] == 29){
a[0] = 1;
a[1]++;
}else{
a[0]++;
}
}else{
a[0] = 1;
a[1]++;
}
}else{
a[1]++;
a[0] = 1;
}
}
if(check(a)){
for(auto k: cur){
dp[k[2]][k[0]][k[1]] = a;
}
cur.clear();
}
cur.pb(a);
}
int t; cin >> t;
for(int i = 0; i < t; ++i){
string s; cin >> s;
a[0] = (s[0]-'0')*10 + (s[1]-'0');
a[1] = (s[3]-'0')*10 + (s[4]-'0');
a[2] = (s[6]-'0')*1000 + (s[7]-'0')*100 + (s[8]-'0')*10 + (s[9]-'0');
cout << pr(dp[a[2]][a[0]][a[1]][0], 0) << '.' << pr(dp[a[2]][a[0]][a[1]][1], 1) << '.' << pr(dp[a[2]][a[0]][a[1]][2], 2) << ".\n";
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// cin >> tt;
while(tt--){
solve();
// en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
datum.cpp: In function 'std::string pr(int, int)':
datum.cpp:14:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
14 | if(tp==0 || tp==1) if(res.length() == 2) return res; else return "0"+res;
| ^
datum.cpp: In function 'bool check(std::array<int, 3>)':
datum.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < s.length()/2; ++i) if(s[i] != s[s.length()-1-i]) return false;
| ~~^~~~~~~~~~~~~~
datum.cpp: In function 'int main()':
datum.cpp:81:15: warning: unused variable 'aa' [-Wunused-variable]
81 | int tt = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
383 ms |
59792 KB |
Output is correct |
2 |
Correct |
385 ms |
58920 KB |
Output is correct |
3 |
Correct |
383 ms |
59312 KB |
Output is correct |
4 |
Correct |
384 ms |
58896 KB |
Output is correct |
5 |
Correct |
388 ms |
60084 KB |
Output is correct |
6 |
Correct |
386 ms |
59060 KB |
Output is correct |
7 |
Correct |
388 ms |
59912 KB |
Output is correct |
8 |
Correct |
396 ms |
58976 KB |
Output is correct |
9 |
Correct |
391 ms |
59964 KB |
Output is correct |
10 |
Correct |
389 ms |
59788 KB |
Output is correct |