結果

問題 No.1318 ABCD quadruplets
ユーザー ikdikd
提出日時 2020-12-16 20:12:45
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,863 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 178,528 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 09:49:31
合計ジャッジ時間 4,929 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 0 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let m: usize = rd.get();
    let mut ans = vec![0u64; n + 1];
    for a in 0..=m {
        let mut s = a;
        for b in a..=m {
            s += b;
            if s > n {
                break;
            }
            for c in b..=m {
                s += c;
                if s > n {
                    break;
                }
                for d in c..=m {
                    s += d;
                    if s > n {
                        break;
                    }
                    if a == b && b == c && c == d && d == a {
                        ans[s] += 1;
                    } else if (a == b && b == c) || (b == c && c == d) || (c == d && d == a) {
                        ans[s] += 4;
                    } else if (a == b && c == d) || (b == c && d == a) {
                        ans[s] += 6;
                    } else if (a == b) || (b == c) || (c == d) || (d == a) {
                        ans[s] += 12;
                    } else {
                        ans[s] += 24;
                    }
                }
            }
        }
    }
    for a in ans {
        println!("{}", a);
    }
}

pub struct ProconReader<R> {
    r: R,
    line: String,
    i: usize,
}

impl<R: std::io::BufRead> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self {
            r: reader,
            line: String::new(),
            i: 0,
        }
    }
    pub fn get<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        self.skip_blanks();
        assert!(self.i < self.line.len());
        assert_ne!(&self.line[self.i..=self.i], " ");
        let line = &self.line[self.i..];
        let end = line.find(' ').unwrap_or_else(|| line.len());
        let s = &line[..end];
        self.i += end;
        s.parse()
            .unwrap_or_else(|_| panic!("parse error `{}`", self.line))
    }
    fn skip_blanks(&mut self) {
        loop {
            let start = self.line[self.i..].find(|ch| ch != ' ');
            match start {
                Some(j) => {
                    self.i += j;
                    break;
                }
                None => {
                    self.line.clear();
                    self.i = 0;
                    let num_bytes = self.r.read_line(&mut self.line).unwrap();
                    assert!(num_bytes > 0, "reached EOF :(");
                    self.line = self.line.trim_end_matches(&['\r', '\n'][..]).to_string();
                }
            }
        }
    }
    pub fn get_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.get()).collect()
    }
}
0