結果

問題 No.1318 ABCD quadruplets
ユーザー fukafukatanifukafukatani
提出日時 2020-12-17 22:23:51
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,562 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 191,672 KB
実行使用メモリ 97,156 KB
最終ジャッジ日時 2023-10-21 07:14:22
合計ジャッジ時間 6,878 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut coefs = vec![HashMap::new(); m * 3 + 1];
    for a in 0..=m {
        for b in 0..=m {
            for c in 0..=m {
                if a + b + c > 600 {
                    break;
                }
                let k = a * a + b * b + c * c + a * c + b * c + b * a;
                *coefs[a + b + c].entry(k).or_insert(0) += 1;
            }
        }
    }
    // debug!(coefs);
    let mut answers = vec![0; 10 * n + 1];
    for coef in 0..=min(3 * m, 600) {
        for d in 0..=m {
            let k1 = d * d + coef * d;
            if k1 > n {
                break;
            }
            for (&k2, &v) in &coefs[coef] {
                answers[k1 + k2] += v;
            }
        }
    }
    for ans in answers.into_iter().take(n + 1) {
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0