5709 2023. 09. 09 18:21:09 TomaSajt Világnaptár (45 pont) cpp17 Elfogadva 45/45 3ms 4204 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> month_lengths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<int> w_month_lengths = {31, 30, 30, 31, 30, 30, 31, 30, 30, 31, 30, 31};

int main() {
  int year, month_ind, month_day_ind;
  cin >> year >> month_ind >> month_day_ind;
  month_day_ind--;
  month_ind--;

  if (year % 4 == 0) {
    month_lengths[1]++;
    w_month_lengths[5]++;
  }

  int day_index = month_day_ind;
  for (int i = 0; i < month_ind; i++) {
    day_index += month_lengths[i];
  }

  int w_month_ind = 0;
  int w_month_day_index = day_index;
  while (w_month_day_index >= w_month_lengths[w_month_ind]) {
    w_month_day_index -= w_month_lengths[w_month_ind];
    w_month_ind++;
  }

  cout << year << ' ' << w_month_ind + 1 << ' ';
  if (w_month_ind == 5 && w_month_day_index == 30) {
    cout << "SZN";
  }
  else if (w_month_ind == 11 && w_month_day_index == 30) {
    cout << "VN";
  }
  else {
    cout << w_month_day_index + 1;
  }
}
Részfeladat Összpont Teszt Verdikt Idő Memória
base 45/45
1 Elfogadva 0/0 3ms 1812 KiB
2 Elfogadva 0/0 3ms 2012 KiB
3 Elfogadva 0/0 3ms 2252 KiB
4 Elfogadva 2/2 3ms 2464 KiB
5 Elfogadva 2/2 3ms 2684 KiB
6 Elfogadva 3/3 3ms 2900 KiB
7 Elfogadva 3/3 3ms 3112 KiB
8 Elfogadva 3/3 3ms 3232 KiB
9 Elfogadva 3/3 3ms 3436 KiB
10 Elfogadva 3/3 3ms 3624 KiB
11 Elfogadva 3/3 3ms 3840 KiB
12 Elfogadva 3/3 2ms 3924 KiB
13 Elfogadva 3/3 3ms 3932 KiB
14 Elfogadva 3/3 2ms 3936 KiB
15 Elfogadva 3/3 3ms 4056 KiB
16 Elfogadva 3/3 3ms 4180 KiB
17 Elfogadva 3/3 3ms 4192 KiB
18 Elfogadva 2/2 2ms 4200 KiB
19 Elfogadva 3/3 2ms 4204 KiB