# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
299152 | quanmcvn | Datum (COCI20_datum) | C++14 | 6 ms | 896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fff "main"
#define For(i,a,b) for (auto i = a; i < b; ++i)
#define pb push_back
#define en cout << '\n';
using namespace std;
typedef signed long long int ll;
typedef std::vector<ll> vll;
ll n;
string a[10000];
vll years_palind;
vector<pair<ll,string> > value;
string palind(ll x){
string res = "****";
For (i,0,4){
res[i] = char(x % 10 + '0');
x /= 10;
}
return res;
}
ll day_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string cvt(ll x, ll dig){
string res; res.resize(dig);
For (i,0,dig){
res[dig - 1 - i] = char(x % 10 + '0');
x /= 10;
}
return res;
}
bool comp_date (string lhs, string rhs){ // less
if (lhs == rhs) return false;
string lmm = lhs.substr(2,2);
string rmm = rhs.substr(2,2);
For (i,0,2){
if (lmm[i] != rmm[i]) return lmm[i] < rmm[i];
}
string ldd = lhs.substr(0,2);
string rdd = rhs.substr(0,2);
For (i,0,2){
if (ldd[i] != rdd[i]) return ldd[i] < rdd[i];
}
}
ll po[] = {1,10,100,1000};
int main()
{
// if (fopen(fff".inp","r")) {
// freopen(fff".inp","r",stdin);
// freopen(fff".out","w",stdout);
// }
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
For (i,0,10000){
string ddmm = palind(i);
ll dd = (ddmm[0] - '0') * 10 + ddmm[1] - '0';
ll mm = (ddmm[2] - '0') * 10 + ddmm[3] - '0';
if (dd > 31 || dd < 1) continue;
if (mm > 12 || mm < 1) continue;
if (i % 4 == 0 && mm == 2) {
if (dd > 29) continue;
}
else if (dd > day_in_month[mm]) continue;
years_palind.pb(i);
value.pb({i,cvt(dd,2) + cvt(mm,2)});
}
cin >> n;
while (n--){
string s; cin >> s;
string ddmm = s.substr(0,2) + s.substr(3,2);
string yyyy = s.substr(6,4); ll yy = 0;
For (i,0,4){
yy += (yyyy[i] - '0') * po[3 - i];
}
ll id = lower_bound(years_palind.begin(),years_palind.end(),yy) - years_palind.begin();
if (years_palind[id] == yy) {
if (!comp_date(ddmm,value[id].second)) id = upper_bound(years_palind.begin(),years_palind.end(),yy) - years_palind.begin();
}
cout << value[id].second.substr(0,2) << '.' << value[id].second.substr(2,2) << '.' << cvt(years_palind[id],4) << '.';
en;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |