結果

問題 No.2929 Miracle Branch
ユーザー Daichi01240124Daichi01240124
提出日時 2024-10-12 16:59:26
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 2,241 bytes
コンパイル時間 26,830 ms
コンパイル使用メモリ 401,856 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-12 17:01:10
合計ジャッジ時間 33,249 ms
ジャッジサーバーID
(参考情報)
judge / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,640 KB
testcase_01 WA -
testcase_02 AC 5 ms
6,816 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
  --> src/main.rs:41:9
   |
41 |     let mut primes = prime_factorization(X);
   |         ----^^^^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

ソースコード

diff #

#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::comparison_chain)]
#![allow(clippy::nonminimal_bool)]
#![allow(clippy::neg_multiply)]
#![allow(dead_code)]
#![allow(clippy::collapsible_else_if)]
use proconio::{
    fastout, input, input_interactive,
    marker::{Chars, Usize1},
};
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;

//const MOD: usize = 1e9 as usize + 7;
const MOD: usize = 998244353;
// const MOD: usize = 2147483647;

#[macro_export]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $( $y: expr ),+) => {
        std::cmp::max($x, max!($( $y ),+))
    }
}
#[macro_export]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $( $y: expr ),+) => {
        std::cmp::min($x, min!($( $y ),+))
    }
}
fn main() {
    input! {
        X:usize,
    }
    let mut primes = prime_factorization(X);
    let mut nodes = vec![];
    let mut edges = vec![];
    for (_, val) in &primes {
        for _ in 0..*val {
            nodes.push('b');
        }
    }
    let mut now = nodes.len();
    let mut idx = 0;
    for (&key, &val) in &primes {
        for _ in 0..val {
            for _ in 0..key {
                if nodes.len() > 200000 {
                    println!("-1");
                    return;
                }
                nodes.push('g');
                edges.push((idx, now));
                now += 1;
            }
            idx += 1;
        }
    }
    if nodes.len() > 200000 {
        println!("-1");
        return;
    }
    println!("{}", nodes.len());
    for (i, j) in edges {
        println!("{} {}", i + 1, j + 1);
    }
    for n in nodes {
        print!("{} ", n);
    }
    println!("");
}
fn prime_factorization(n: usize) -> HashMap<usize, usize> {
    let mut n = n;
    let mut map = HashMap::new();
    if n == 1 {
        map.insert(1, 1);
        return map;
    }
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            *map.entry(i).or_insert(0) += 1;
            n /= i;
        }
        i += 1;
    }
    if n > 1 {
        map.insert(n, 1);
    }
    map
}
0