# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
998976 | vjudge1 | Datum (COCI20_datum) | C++17 | 349 ms | 444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
bool check(string s)
{
int m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(stoi(s) % 4 == 0)
m[1] = 29;
string MM; MM += s[1], MM += s[0];
if(stoi(MM) <= 0 || stoi(MM) > 12)
return false;
int idx = stoi(MM) - 1;
string DD; DD += s[3], DD += s[2];
if(stoi(DD) <= 0 || stoi(DD) > m[idx])
return false;
return true;
}
bool compare(string a, string b)
{
if(a.substr(3, 2) != b.substr(3, 2)) return a.substr(3, 2) < b.substr(3, 2);
return a.substr(0, 2) < b.substr(0, 2);
}
void solve()
{
string date;
cin >> date;
string Y = date.substr(6, 4);
string ans;
ans += Y[3], ans += Y[2], ans += '.', ans += Y[1], ans += Y[0], ans += '.';
ans += Y, ans += '.';
if(check(Y) && compare(date, ans))
{
cout << Y[3] << Y[2] << '.' << Y[1] << Y[0] << '.' << Y << ".\n";
return;
}
while(true)
{
int s = stoi(Y) + 1;
Y = to_string(s);
while(Y.size() < 4)
Y = '0' + Y;
if(check(Y))
break;
}
cout << Y[3] << Y[2] << '.' << Y[1] << Y[0] << '.' << Y << ".\n";
}
int main()
{
int t;
cin >> t;
while(t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |