結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー rpy3cpprpy3cpp
提出日時 2018-08-11 15:05:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,499 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 208,020 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 13:54:10
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'std::tuple<int, int, int> next_day(int, int, int)':
main.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


tuple<int, int, int> parse_date(string &S){
    int y, m, d;
    y = (S[0]-'0') * 1000 + (S[1]-'0') * 100 + (S[2]-'0') * 10 + S[3] - '0';
    m = (S[5]-'0') * 10 + (S[6]-'0');
    d = (S[8]-'0') * 10 + (S[9]-'0');
    return {y, m, d};
}

bool isLeap(int y){
    if (y % 4) return false;
    if (y % 400 == 0) return true;
    if (y % 100 == 0) return false;
    return true;
}

tuple<int, int, int> next_day(int y, int m, int d){
    if (d < 28){
        return {y, m, d + 1};
    }
    if (d == 28){
        if (m != 2){
            return {y, m, d + 1};
        }else{
            if (isLeap(y)){
                return {y, m, d + 1};
            }else{
                return {y, 3, 1};
            }
        }
    }
    if (d == 29){
        if (m == 2){
            return {y, 3, 1};
        }else{
            return {y, m, d + 1};
        }
    }
    if (d == 30){
        if (m == 4 or m == 6 or m == 9 or m == 11){
            return {y, m + 1, 1};
        }else{
            return {y, m, 31};
        }
    }
    if (d == 31){
        if (m == 12){
            return {y + 1, 1, 1};
        }else{
            return {y, m + 1, 1};
        }
    }
}


int main() {
    string S;
    cin >> S;
    auto [y, m, d] = parse_date(S);
    tie(y, m, d) = next_day(y, m, d);
    tie(y, m, d) = next_day(y, m, d);
    cout << y << '/' << setfill('0') << setw(2) << right << m << '/' << setfill('0') << setw(2) << right << d << endl;
    return 0;
}
0