提出 #39518098


ソースコード 拡げる

use proconio::{input, marker::Chars};

fn main() {
    input! {
        s: Chars,
        t: Chars,
    };
    let s_y = s[0..4].iter().collect::<String>().parse::<usize>().unwrap();
    let s_m = s[5..7].iter().collect::<String>().parse::<usize>().unwrap();
    let s_d = s[8..10]
        .iter()
        .collect::<String>()
        .parse::<usize>()
        .unwrap();
    let t_y = t[0..4].iter().collect::<String>().parse::<usize>().unwrap();
    let t_m = t[5..7].iter().collect::<String>().parse::<usize>().unwrap();
    let t_d = t[8..10]
        .iter()
        .collect::<String>()
        .parse::<usize>()
        .unwrap();
    let mut count = 0_usize;
    let mut weekday = 5;
    let mut is_in = false;
    for y in 2022..=9999 {
        let is_leap_year = (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
        for m in 1..=12 {
            let days_of_month = vec![
                0,
                31,
                if is_leap_year { 29 } else { 28 },
                31,
                30,
                31,
                30,
                31,
                31,
                30,
                31,
                30,
                31,
            ];
            for d in 1..=days_of_month[m] {
                if y == s_y && m == s_m && d == s_d {
                    is_in = true;
                }
                if is_in && (weekday == 5 || weekday == 6) {
                    count += 1;
                }

                if y == t_y && m == t_m && d == t_d {
                    is_in = false;
                }

                weekday += 1;
                weekday %= 7;
            }
        }
    }
    println!("{}", count);
}

提出情報

提出日時
問題 J - 完全週休二日制
ユーザ bouzuya
言語 Rust (1.42.0)
得点 6
コード長 1679 Byte
結果 AC
実行時間 29 ms
メモリ 2132 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 6 / 6
結果
AC × 3
AC × 26
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 29 ms 2016 KiB
random_02.txt AC 23 ms 2012 KiB
random_03.txt AC 16 ms 1960 KiB
random_04.txt AC 20 ms 2016 KiB
random_05.txt AC 17 ms 2092 KiB
random_06.txt AC 17 ms 2132 KiB
random_07.txt AC 16 ms 2104 KiB
random_08.txt AC 17 ms 2092 KiB
random_09.txt AC 19 ms 2044 KiB
random_10.txt AC 17 ms 2044 KiB
random_11.txt AC 18 ms 2064 KiB
random_12.txt AC 18 ms 1936 KiB
random_13.txt AC 20 ms 2004 KiB
random_14.txt AC 17 ms 2048 KiB
random_15.txt AC 19 ms 1932 KiB
random_16.txt AC 17 ms 1864 KiB
random_17.txt AC 17 ms 1988 KiB
random_18.txt AC 19 ms 2100 KiB
random_19.txt AC 20 ms 2044 KiB
random_20.txt AC 19 ms 2064 KiB
random_21.txt AC 18 ms 2060 KiB
random_22.txt AC 19 ms 2072 KiB
random_23.txt AC 19 ms 1976 KiB
sample_01.txt AC 28 ms 2008 KiB
sample_02.txt AC 16 ms 1984 KiB
sample_03.txt AC 19 ms 2020 KiB