# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335241 | ronnith | Datum (COCI20_datum) | C++14 | 1097 ms | 364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
// char ss[100];
bool pal(string a){
int n = a.size();
for(int i = 0;i < 8;i ++){
if(a[i] != a[n - i - 1])return false;
}
return true;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tt;
cin >> tt;
int m1[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int m2[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
while(tt --){
string s;
cin >> s;
int dd = (s[0] - '0') * 10 + (s[1] - '0');
int mm = (s[3] - '0') * 10 + (s[4] - '0');
int yy = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
for(int i = mm;i <= 12;i ++){
bool done = false;
for(int j = ((i == mm)?dd:1);j <= ((yy % 4 == 0)?m2[i - 1]:m1[i - 1]);j ++){
stringstream ss;
ss << j / 10 << j % 10 << i / 10 << i % 10 << (yy / 1000) % 10 << (yy / 100) % 10 << (yy / 10) % 10 << yy % 10;
// cerr << ss.str() << '\n';
if(pal(ss.str())){
// cerr << "yes";
done = true;
stringstream ans;
ans << j / 10 << j % 10 << '.' << i / 10 << i % 10 << '.' << (yy / 1000) % 10 << (yy / 100) % 10 << (yy / 10) % 10 << yy % 10 << '.';
cout << ans.str() << '\n';
break;
}
}
if(done)break;
}
// for(int i = dd + 1;i <= 31;i ++){
// }
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |