うーん、こういうのはイテレータだけでもいけるね
ttps://atcoder.jp/contests/abc138/tasks/abc138_d
static mut tree_list: Vec<(i64, i64)> = Vec::new();
static mut job_list: Vec<(i64, i64)> = Vec::new();
static mut res_list: Vec<i64> = Vec::new();
fn main() {
unsafe {
input! {
edge: i64, job: i64,
tree_list0: [(i64, i64); edge-1],
job_list0: [(i64, i64); job],
}
tree_list = tree_list0;
job_list = job_list0;
res_list = vec![0_i64; edge as usize + 1];
unsafe fn calc(index: i64, count: i64) {
res_list[index as usize] += count;
for &(a, b) in &tree_list { if a == index { calc(b, count); } }
}
for &(a, b) in &job_list { calc(a, b); }
for i in 1..res_list.len() { print!("{} ", res_list[i]); }
println!();
}
}
Rust part12
■ このスレッドは過去ログ倉庫に格納されています
268デフォルトの名無しさん
2021/09/01(水) 21:38:57.15ID:8EcW0Jj4■ このスレッドは過去ログ倉庫に格納されています
