結果

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

ソースコード

diff #
raw source code

ys, ms, ds = map(int, input().split())
ye, me, de = map(int, input().split())
Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]

def is_leap(year):
    return year%4 == 0 and not (year%100 == 0 and year%400 != 0)
def day_count(year, month):
    if month == 2:
        if is_leap(year):
            return 29
        else:
            return 28
    elif month in [4, 6, 9, 11]:
        return 30
    else:
        return 31
def range_count(ys, ms, ds, ye, me, de):
    if (ys, ms) == (ye, me):
        return de-ds+1
    if ys == ye:
        ans = 1-ds
        for month in range(ms, me):
            ans += day_count(ys, month)
        ans += de
        return ans
    ans = 1-ds
    for month in range(ms, 13):
        ans += day_count(ys, month)
    for year in range(ys+1, ye):
        if is_leap(year):
            ans += 366
        else:
            ans += 365
    for month in range(1, me):
        ans += day_count(ye, month)
    ans += de
    return ans

first_count = range_count(ys, ms, ds, ye, me, de)
for y, m, d in query:
    second_count = range_count(ye, me, de, y, m, d)-1
    if second_count < first_count:
        print("Less")
    elif second_count == first_count:
        print("Same")
    else:
        print("More")
0