#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define PB push_back
using namespace std;
const int N = 4000100;
const int oo = 2e9;
string s, t;
vector<array<int, 3> > vc;
int moths[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int nearest[N];
string tostr(int x, int len){
string res = "";
for (int it = 0; it < len; it++){
res += char(x % 10 + '0');
x /= 10;
}
reverse(all(res));
return res;
}
bool pali(int id){
s = "";
s += tostr(vc[id][2], 2);
s += tostr(vc[id][1], 2);
s += tostr(vc[id][0], 4);
t = s;
reverse(all(t));
return (s == t);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
for (int year = 1; year < 10000; year++)
for (int mon = 0; mon < 12; mon++){
int kol_days = moths[mon];
if (year % 4 == 0 && mon == 1)
kol_days++;
for (int days = 1; days <= kol_days; days++)
vc.PB({year, mon + 1, days});
}
nearest[sz(vc) - 1] = sz(vc);
for (int i = sz(vc) - 2; i >= 0; i--)
if (pali(i + 1))
nearest[i] = i + 1;
else nearest[i] = nearest[i + 1];
int qq; cin >> qq;
for (; qq; qq--){
int d, m, y;
scanf("%d.%d.%d.", &d, &m, &y);
array<int, 3> ar = {y, m, d};
int loc = lower_bound(all(vc), ar) - vc.begin();
int id = nearest[loc];
cout << tostr(vc[id][2], 2) << "." << tostr(vc[id][1], 2) << "." << tostr(vc[id][0], 4) << ".\n";
}
return 0;
}
Compilation message
datum.cpp: In function 'int main()':
datum.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d.%d.%d.", &d, &m, &y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
501 ms |
57592 KB |
Output isn't correct |
2 |
Incorrect |
500 ms |
57852 KB |
Output isn't correct |
3 |
Incorrect |
495 ms |
57584 KB |
Output isn't correct |
4 |
Incorrect |
492 ms |
57696 KB |
Output isn't correct |
5 |
Incorrect |
512 ms |
57692 KB |
Output isn't correct |
6 |
Incorrect |
479 ms |
57588 KB |
Output isn't correct |
7 |
Incorrect |
502 ms |
57644 KB |
Output isn't correct |
8 |
Incorrect |
521 ms |
57788 KB |
Output isn't correct |
9 |
Incorrect |
461 ms |
57592 KB |
Output isn't correct |
10 |
Incorrect |
501 ms |
57780 KB |
Output isn't correct |