結果

問題 No.3402 [Cherry Anniversary 5] Beyond Zelkova, the 5th year vista seen through the bloom of a cherry bloosom
コンテスト
ユーザー 👑 Kazun
提出日時 2025-12-01 01:33:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 2,050 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 376 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 77,548 KB
最終ジャッジ日時 2025-12-08 23:30:05
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 方針 2: 特定の日からの日付に帰着させる.

def is_leap(year: int) -> bool:
    """ 西暦 year 年はうるう年?

    Args:
        year (int): 西暦

    Returns:
        bool: うるう年?
    """
    if year % 100 == 0:
        return year % 400 == 0

    return year % 4 == 0

def days_in_month(year: int, month: int) -> int:
    """ 西暦 year 年 month 月の日数

    Args:
        year (int): 西暦
        month (int): 月

    Returns:
        int: 日数
    """

    if month == 2:
        return 29 if is_leap(year) else 28

    return 30 if month in [4, 6, 9, 11] else 31

def get_total_days_from_19321231(year: int, month: int, day: int) -> int:
    """ 1932/12/31 を 0 日目とした場合の通算日数を求める.

    Args:
        year (int): 年
        month (int): 月
        day (int): 日

    Returns:
        int: 通算日数
    """
    total_days = 0

    # I: 1933 年から (year - 1) 年まで
    for y in range(1933, year):
        total_days += 366 if is_leap(y) else 365

    # II: year 年 1 月から year 年 (month - 1) 月まで
    for m in range(1, month):
        total_days += days_in_month(year, m)

    # III: year 年 month 月の day 日間
    total_days += day

    return total_days

#==================================================
def solve():
    ys, ms, ds = map(int, input().split())
    ye, me, de = map(int, input().split())

    N_s = get_total_days_from_19321231(ys, ms, ds)
    N_e = get_total_days_from_19321231(ye, me, de)
    b = N_e - N_s + 1

    Q = int(input())
    ans = [None] * Q
    for q in range(Q):
        y, m, d = map(int, input().split())
        N_q = get_total_days_from_19321231(y, m, d)
        a = N_q - (N_e + 1) + 1

        if a < b:
            ans[q] = "Less"
        elif a == b:
            ans[q] = "Same"
        elif a > b:
            ans[q] = "More"

    return ans

#==================================================
import sys
input = sys.stdin.readline
write = sys.stdout.write

write("\n".join(map(str, solve())))
0