Submission #33018386
Source Code Expand
use std::collections::BinaryHeap;
use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
};
let mut t = vec![];
let mut a = vec![];
for _ in 0..n {
input! {
t_i: usize,
k_i: usize,
a_i: [Usize1; k_i]
};
t.push(t_i);
a.push(a_i);
}
let mut pq = BinaryHeap::new();
let mut used = vec![false; n];
let mut sum = t[n - 1];
used[n - 1] = true;
pq.push(n - 1);
while let Some(i) = pq.pop() {
for j in a[i].iter().copied() {
if used[j] {
continue;
}
sum += t[j];
used[j] = true;
pq.push(j);
}
}
let ans = sum;
println!("{}", ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Martial artist |
| User | bouzuya |
| Language | Rust (1.42.0) |
| Score | 300 |
| Code Size | 772 Byte |
| Status | AC |
| Exec Time | 63 ms |
| Memory | 18356 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_00.txt, 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 7 ms | 2032 KiB |
| example_01.txt | AC | 4 ms | 2068 KiB |
| hand_00.txt | AC | 11 ms | 4156 KiB |
| hand_01.txt | AC | 51 ms | 18356 KiB |
| hand_02.txt | AC | 63 ms | 15560 KiB |
| hand_03.txt | AC | 27 ms | 9228 KiB |
| hand_04.txt | AC | 2 ms | 1932 KiB |
| random_00.txt | AC | 54 ms | 17160 KiB |
| random_01.txt | AC | 56 ms | 16944 KiB |
| random_02.txt | AC | 46 ms | 15732 KiB |
| random_03.txt | AC | 45 ms | 15824 KiB |
| random_04.txt | AC | 46 ms | 15788 KiB |
| random_05.txt | AC | 42 ms | 14032 KiB |
| random_06.txt | AC | 41 ms | 14184 KiB |
| random_07.txt | AC | 42 ms | 14096 KiB |
| random_08.txt | AC | 42 ms | 13608 KiB |
| random_09.txt | AC | 41 ms | 13736 KiB |
| random_10.txt | AC | 41 ms | 13660 KiB |
| random_11.txt | AC | 40 ms | 13512 KiB |
| random_12.txt | AC | 38 ms | 13336 KiB |
| random_13.txt | AC | 38 ms | 13480 KiB |
| random_14.txt | AC | 40 ms | 13468 KiB |
| random_15.txt | AC | 40 ms | 13352 KiB |
| random_16.txt | AC | 40 ms | 13512 KiB |
| random_17.txt | AC | 40 ms | 13332 KiB |