Submission #29419941
Source Code Expand
Copy
use proconio::input;fn dijkstra(n: usize, inf: u64, e: &[Vec<(usize, u64)>], s: usize) -> Vec<u64> {use std::{cmp::Reverse, collections::BinaryHeap};let mut d = vec![inf; n];let mut pq = BinaryHeap::new();d[s] = 0;pq.push(Reverse((0, s)));while let Some(Reverse((w_u, u))) = pq.pop() {if w_u > d[u] {continue;}for (v, w_v) in e[u].iter().copied() {let w = w_u + w_v;if w < d[v] {d[v] = w;pq.push(Reverse((w, v)));}}}d
use proconio::input; fn dijkstra(n: usize, inf: u64, e: &[Vec<(usize, u64)>], s: usize) -> Vec<u64> { use std::{cmp::Reverse, collections::BinaryHeap}; let mut d = vec![inf; n]; let mut pq = BinaryHeap::new(); d[s] = 0; pq.push(Reverse((0, s))); while let Some(Reverse((w_u, u))) = pq.pop() { if w_u > d[u] { continue; } for (v, w_v) in e[u].iter().copied() { let w = w_u + w_v; if w < d[v] { d[v] = w; pq.push(Reverse((w, v))); } } } d } fn main() { input! { k: usize, }; let mut edges = vec![vec![]; k]; for i in 1..k { edges[i % k].push(((10 * i) % k, 0)); edges[i % k].push(((i + 1) % k, 1)); } let inf = 1_u64 << 60; let dist = dijkstra(k, inf, &edges, 1); println!("{}", dist[0] + 1); }
Submission Info
Submission Time | |
---|---|
Task | 048 - Small Multiple |
User | bouzuya |
Language | Rust (1.42.0) |
Score | 700 |
Code Size | 896 Byte |
Status | AC |
Exec Time | 51 ms |
Memory | 10516 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 6 ms | 2096 KB |
02.txt | AC | 2 ms | 2060 KB |
03.txt | AC | 2 ms | 2048 KB |
04.txt | AC | 1 ms | 2080 KB |
05.txt | AC | 2 ms | 1968 KB |
06.txt | AC | 2 ms | 2076 KB |
07.txt | AC | 2 ms | 2016 KB |
08.txt | AC | 1 ms | 1984 KB |
09.txt | AC | 2 ms | 1908 KB |
10.txt | AC | 1 ms | 2012 KB |
11.txt | AC | 1 ms | 1896 KB |
12.txt | AC | 4 ms | 1940 KB |
13.txt | AC | 2 ms | 2024 KB |
14.txt | AC | 2 ms | 1940 KB |
15.txt | AC | 2 ms | 2056 KB |
16.txt | AC | 3 ms | 2028 KB |
17.txt | AC | 2 ms | 2016 KB |
18.txt | AC | 2 ms | 1916 KB |
19.txt | AC | 2 ms | 2008 KB |
20.txt | AC | 2 ms | 2080 KB |
21.txt | AC | 36 ms | 9948 KB |
22.txt | AC | 37 ms | 9836 KB |
23.txt | AC | 40 ms | 10516 KB |
24.txt | AC | 50 ms | 10476 KB |
25.txt | AC | 39 ms | 10204 KB |
26.txt | AC | 39 ms | 10280 KB |
27.txt | AC | 43 ms | 10496 KB |
28.txt | AC | 40 ms | 10516 KB |
29.txt | AC | 42 ms | 10252 KB |
30.txt | AC | 51 ms | 10468 KB |
31.txt | AC | 2 ms | 2036 KB |
32.txt | AC | 2 ms | 2020 KB |
33.txt | AC | 44 ms | 8308 KB |
34.txt | AC | 19 ms | 5188 KB |
35.txt | AC | 39 ms | 7788 KB |
36.txt | AC | 36 ms | 9668 KB |
37.txt | AC | 16 ms | 4080 KB |
38.txt | AC | 20 ms | 5240 KB |
39.txt | AC | 22 ms | 6284 KB |
40.txt | AC | 3 ms | 2476 KB |
41.txt | AC | 39 ms | 9064 KB |
42.txt | AC | 37 ms | 10012 KB |
43.txt | AC | 7 ms | 2860 KB |
44.txt | AC | 3 ms | 2328 KB |
45.txt | AC | 27 ms | 6256 KB |
46.txt | AC | 29 ms | 6980 KB |
47.txt | AC | 3 ms | 2456 KB |
48.txt | AC | 38 ms | 9424 KB |
49.txt | AC | 35 ms | 8884 KB |
50.txt | AC | 28 ms | 6548 KB |
51.txt | AC | 14 ms | 3764 KB |
52.txt | AC | 21 ms | 5692 KB |
53.txt | AC | 29 ms | 7748 KB |
54.txt | AC | 19 ms | 4836 KB |
55.txt | AC | 23 ms | 6184 KB |
56.txt | AC | 25 ms | 7736 KB |
57.txt | AC | 39 ms | 9828 KB |
58.txt | AC | 24 ms | 6924 KB |
59.txt | AC | 34 ms | 8568 KB |
60.txt | AC | 24 ms | 7280 KB |
61.txt | AC | 12 ms | 3524 KB |
62.txt | AC | 19 ms | 5980 KB |
63.txt | AC | 39 ms | 9884 KB |
64.txt | AC | 36 ms | 9992 KB |
s1.txt | AC | 2 ms | 2016 KB |
s2.txt | AC | 2 ms | 2032 KB |
s3.txt | AC | 33 ms | 8328 KB |