#include <bits/stdc++.h>
#define int long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
const double EPS = 0.00001;
const int INF = 1e9+500;
const int MOD = 1e9+7;
const int N = 55;
const int K = 1505;
const int ALPH = 26;
int n,m,q,k;
vector<int> c = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<array<int,3> > a;
bool valid_date(array<int,3> x) {
if(x[1] == 2) {
if(x[0] == 29) {
if(x[2] % 4 == 0) return true;
else return false;
}
}
//cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<"\n";
if(x[1] > 12) return 0;
if(x[1] == 0) return 0;
assert(x[1] <= 12 && x[1] > 0);
if(x[2] == 0) return 0;
if(x[0] == 0) return 0;
if(c[x[1]] < x[0]) return false;
return 1;
}
array<int,3> parse_date(string s) {
array<int,3> res;
res[0] = (s[0] - '0') * 10 + (s[1] - '0');
res[1] = (s[3] - '0') * 10 + (s[4] - '0');
res[2] = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
return res;
}
string encod(array<int,3> x) {
string res;
res.resize(11);
res[1] = '0' + (x[0] % 10);
x[0] /= 10;
res[0] = '0' + (x[0] %10);
res[2] = '.';
res[4] = '0' + (x[1] % 10);
x[1] /= 10;
res[3] = '0' + (x[1] %10);
res[5] = '.';
res[9] = '0' + (x[2] % 10);
x[2] /= 10;
res[8] = '0' + (x[2] %10);
x[2] /= 10;
res[7] = '0' + (x[2] % 10);
x[2] /= 10;
res[6] = '0' + (x[2] %10);
res[10] = '.';
return res;
}
array<int,3> palind_date(int year) {
int tmp = year;
int day = (tmp % 10) * 10;
tmp/=10;
day += (tmp % 10);
tmp/=10;
int month = (tmp % 10) * 10;
tmp/=10;
month += (tmp % 10);
if( valid_date({day, month, year}) ) {
return {day,month,year};
}
return {-1,-1,-1};
}
vector<string> prec(3201);
void solve() {
cin>>n;
a.resize(n);
for(int i = 0; i<n; i++) {
string tmp;
cin>>tmp;
a[i] = parse_date(tmp);
}
string last = "";
array<int,3> z = {-1,-1,-1};
for(int i = 3200; i>=0; i--) {
prec[i] = last;
if(palind_date(i) != z) {
last = encod(palind_date(i));
}
}
for(int i = 0; i<n; i++) {
cout<<prec[a[i][2]]<<"\n";
}
}
signed main() {
int test = 1;
//cin>>test;
while(test--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Runtime error |
3 ms |
1316 KB |
Execution killed with signal 11 |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
10 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |