# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
845143 | vjudge1 | Datum (COCI20_datum) | C++17 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
using namespace std;
int mp[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
constexpr static int M = 100;
constexpr static int Y = 10000;
bool is_palindrome(const char* s)
{
for (int i = 0; i < 4; i++)
if (s[i] != s[7-i])
return false;
return true;
}
int32_t main()
{
vector<int> v;
for (int y = 1; y <= 9999; y++)
{
for (int m = 1; m <= 12; m++)
{
int td = mp[m];
if (m == 2 && ((y%4) == 0))
td = 29;
for (int d = 1; d <= td; d++)
{
char ss[8];
sprintf(ss, "%02d%02d%04d", d, m, y);
if (is_palindrome(ss))
v.pb(d + m * M + y * Y);
}
}
}
int q;
cin >> q;
while (q--)
{
string s;
cin >> s;
int d = (s[0]-'0') * 10 + (s[1]-'0'), m = (s[3]-'0') * 10 + (s[4]-'0'), y = (s[6]-'0') * 1000 + (s[7]-'0') * 100 + (s[8]-'0') * 10 + (s[9]-'0');
int res = *upper_bound(v.begin(), v.end(), y * Y + m * M + d);
cout << res << "\n";
printf("%02d.%02d.%04d.\n", res % M, (res % Y) / M, res / Y);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |