답안 #998972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998972 2024-06-15T02:50:43 Z vjudge1 Datum (COCI20_datum) C++17
20 / 50
328 ms 600 KB
#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;
}

void solve()
{
  string date;
  cin >> date;

  string DM = date.substr(0, 2) + date.substr(3, 2);
  string Y = date.substr(6, 4);

  reverse(DM.begin(), DM.end());

  if(DM < Y && check(Y))
    {
      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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 296 ms 600 KB Output isn't correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 328 ms 560 KB Output isn't correct