Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You are given an undirected connected weighted graph consisting of n vertices and m edges. Let's denote the length of the shortest path from vertex 1 to vertex i as d_i . You have to erase some edges of the graph so that at most k edges remain. Let's call a vertex i good if there still exists a path from 1 to i with length d_i after erasing the edges. Your goal is to erase the edges in such a way that the number of good vertices is maximized. The first line contains three integers n , m and k ( 2 <= n <= 3 cdot 10^5 , 1 <= m <= 3 cdot 10^5 , n - 1 <= m , 0 <= k <= m ) -- the number of vertices and edges in the graph, and the maximum number of edges that can be retained in the graph, respectively. Then m lines follow, each containing three integers x , y , w ( 1 <= x, y <= n , x ne y , 1 <= w <= 10^9 ), denoting an edge connecting vertices x and y and having weight w . The given graph is connected (any vertex can be reached from any other vertex) and simple (there are no self-loops, and for each unordered pair of vertices there exists at most one edge connecting these vertices). In the first line print e -- the number of edges that should remain in the graph ( 0 <= e <= k ). In the second line print e distinct integers from 1 to m -- the indices of edges that should remain in the graph. Edges are numbered in the same order they are given in the input. The number of good vertices should be as large as possible. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
53124499 |
rr_ |
D |
April 22, 2019, 1:09 p.m. |
OK |
D |
TESTS |
73 |
670 |
54169600 |
|
1800 |
52445041 |
sansen |
D |
April 7, 2019, 7:42 a.m. |
OK |
GNU C11 |
TESTS |
73 |
202 |
23040000 |
|
1800 |
49505328 |
rainboy |
D |
Feb. 5, 2019, 5:14 p.m. |
OK |
GNU C11 |
TESTS |
73 |
1247 |
18022400 |
|
1800 |
45786754 |
secret42 |
D |
Nov. 16, 2018, 2:43 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
202 |
32870400 |
|
1800 |
45904649 |
qrsikno1 |
D |
Nov. 18, 2018, 7:43 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
217 |
24883200 |
|
1800 |
45652558 |
Dedicatus545 |
D |
Nov. 13, 2018, 3:04 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
217 |
29286400 |
|
1800 |
45660770 |
wzj_xhjbk |
D |
Nov. 13, 2018, 6:27 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
20070400 |
|
1800 |
45651967 |
Epikem |
D |
Nov. 13, 2018, 2:26 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
20172800 |
|
1800 |
46109952 |
Itst |
D |
Nov. 23, 2018, 11:40 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
20684800 |
|
1800 |
45771965 |
zhenGG |
D |
Nov. 15, 2018, 2:58 p.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
21811200 |
|
1800 |
45651637 |
Enfris |
D |
Nov. 13, 2018, 2:03 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
24576000 |
|
1800 |
45948185 |
vjudge3 |
D |
Nov. 19, 2018, 3:13 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
218 |
24883200 |
|
1800 |
45750441 |
PureWhite |
D |
Nov. 15, 2018, 12:21 a.m. |
OK |
GNU C++11 |
TESTS |
73 |
233 |
15769600 |
|
1800 |
45772895 |
luongskyfa |
D |
Nov. 15, 2018, 3:27 p.m. |
OK |
GNU C++14 |
TESTS |
73 |
233 |
23040000 |
|
1800 |
45660911 |
sunshiness |
D |
Nov. 13, 2018, 6:31 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
233 |
27648000 |
|
1800 |
45700208 |
Xin-Jie |
D |
Nov. 14, 2018, 7:36 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
265 |
18022400 |
|
1800 |
45768264 |
834929914 |
D |
Nov. 15, 2018, 1:14 p.m. |
OK |
GNU C++14 |
TESTS |
73 |
311 |
23756800 |
|
1800 |
45632814 |
tokitsukaze |
D |
Nov. 12, 2018, 5:38 p.m. |
OK |
GNU C++14 |
TESTS |
73 |
311 |
42598400 |
|
1800 |
45757925 |
wangshu |
D |
Nov. 15, 2018, 7:17 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
312 |
22016000 |
|
1800 |
45655334 |
nickluo |
D |
Nov. 13, 2018, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
326 |
39014400 |
|
1800 |
45705978 |
xuyu070926 |
D |
Nov. 14, 2018, 11:35 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
327 |
19865600 |
|
1800 |
45653354 |
purple_bro |
D |
Nov. 13, 2018, 4:01 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
327 |
23040000 |
|
1800 |
45673533 |
jianwei2017 |
D |
Nov. 13, 2018, 11:57 a.m. |
OK |
GNU C++14 |
TESTS |
73 |
327 |
42393600 |
|
1800 |
45694434 |
DevilInChina |
D |
Nov. 14, 2018, 1:02 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
171 |
23244800 |
|
1800 |
45694417 |
DevilInChina |
D |
Nov. 14, 2018, 1 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
280 |
35123200 |
|
1800 |
66539253 |
baiyifeng |
D |
Dec. 9, 2019, 10:50 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
311 |
36966400 |
|
1800 |
45713609 |
yintama |
D |
Nov. 14, 2018, 3:27 p.m. |
OK |
GNU C++17 |
TESTS |
73 |
327 |
19046400 |
|
1800 |
45751429 |
HIT_Attacker |
D |
Nov. 15, 2018, 1:34 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
327 |
26521600 |
|
1800 |
51386323 |
.tx |
D |
March 16, 2019, 6:58 p.m. |
OK |
GNU C++17 |
TESTS |
73 |
327 |
33587200 |
|
1800 |
45669468 |
alkil |
D |
Nov. 13, 2018, 9:39 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
327 |
38809600 |
|
1800 |
57336095 |
RSHS |
D |
July 19, 2019, 4:08 p.m. |
OK |
GNU C++17 |
TESTS |
73 |
342 |
19558400 |
|
1800 |
66538822 |
baiyifeng |
D |
Dec. 9, 2019, 10:43 a.m. |
OK |
GNU C++17 |
TESTS |
73 |
342 |
36966400 |
|
1800 |
57512391 |
LiM_256 |
D |
July 22, 2019, 2:20 p.m. |
OK |
GNU C++17 |
TESTS |
73 |
343 |
21606400 |
|
1800 |
69412449 |
TheSawan |
D |
Jan. 23, 2020, 12:04 p.m. |
OK |
Java 11 |
TESTS |
73 |
1106 |
70963200 |
|
1800 |
46217285 |
revanthreddy85 |
D |
Nov. 25, 2018, 5:28 p.m. |
OK |
Java 8 |
TESTS |
73 |
857 |
78950400 |
|
1800 |
45697008 |
xyz_000 |
D |
Nov. 14, 2018, 4:41 a.m. |
OK |
Java 8 |
TESTS |
73 |
857 |
80793600 |
|
1800 |
54778675 |
caoash |
D |
May 28, 2019, 7:41 p.m. |
OK |
Java 8 |
TESTS |
73 |
872 |
75571200 |
|
1800 |
46293144 |
tsumit023 |
D |
Nov. 27, 2018, 9:47 p.m. |
OK |
Java 8 |
TESTS |
73 |
873 |
78028800 |
|
1800 |
46993607 |
Faizan |
D |
Dec. 14, 2018, 6:47 a.m. |
OK |
Java 8 |
TESTS |
73 |
951 |
81920000 |
|
1800 |
46994005 |
Faizan |
D |
Dec. 14, 2018, 7:06 a.m. |
OK |
Java 8 |
TESTS |
73 |
951 |
82944000 |
|
1800 |
69001027 |
chojh1222 |
D |
Jan. 17, 2020, 7:37 p.m. |
OK |
Java 8 |
TESTS |
73 |
967 |
74547200 |
|
1800 |
46993505 |
Faizan |
D |
Dec. 14, 2018, 6:42 a.m. |
OK |
Java 8 |
TESTS |
73 |
967 |
81920000 |
|
1800 |
45660505 |
amolpratap007 |
D |
Nov. 13, 2018, 6:17 a.m. |
OK |
Java 8 |
TESTS |
73 |
982 |
87244800 |
|
1800 |
45633807 |
guptautkarsh028 |
D |
Nov. 12, 2018, 6:02 p.m. |
OK |
Java 8 |
TESTS |
73 |
997 |
78848000 |
|
1800 |
48282085 |
eki |
D |
Jan. 12, 2019, 8:29 a.m. |
OK |
Mono C# |
TESTS |
73 |
2246 |
51507200 |
|
1800 |
48869776 |
scorpiowf |
D |
Jan. 24, 2019, 5:22 a.m. |
OK |
MS C++ |
TESTS |
73 |
280 |
24780800 |
|
1800 |
45672621 |
Houbunsha |
D |
Nov. 13, 2018, 11:30 a.m. |
OK |
MS C++ |
TESTS |
73 |
311 |
27955200 |
|
1800 |
52347613 |
vjudge4 |
D |
April 5, 2019, 1:19 p.m. |
OK |
MS C++ |
TESTS |
73 |
327 |
21401600 |
|
1800 |
45765770 |
wjfwjfwjf |
D |
Nov. 15, 2018, 12:04 p.m. |
OK |
MS C++ |
TESTS |
73 |
358 |
24576000 |
|
1800 |
49817738 |
vjudge1 |
D |
Feb. 12, 2019, 6:59 a.m. |
OK |
MS C++ |
TESTS |
73 |
451 |
28876800 |
|
1800 |
46855599 |
vjudge5 |
D |
Dec. 10, 2018, 2:38 p.m. |
OK |
MS C++ |
TESTS |
73 |
451 |
35737600 |
|
1800 |
49821164 |
vjudge2 |
D |
Feb. 12, 2019, 8:57 a.m. |
OK |
MS C++ |
TESTS |
73 |
468 |
28876800 |
|
1800 |
46769123 |
vjudge3 |
D |
Dec. 8, 2018, 3:56 p.m. |
OK |
MS C++ |
TESTS |
73 |
483 |
33075200 |
|
1800 |
46897322 |
vjudge2 |
D |
Dec. 11, 2018, 10:02 a.m. |
OK |
MS C++ |
TESTS |
73 |
483 |
35737600 |
|
1800 |
50562818 |
vjudge4 |
D |
Feb. 27, 2019, 11:53 a.m. |
OK |
MS C++ |
TESTS |
73 |
545 |
31129600 |
|
1800 |
64092525 |
vjudge1 |
D |
Nov. 2, 2019, 1:02 p.m. |
OK |
MS C++ 2017 |
TESTS |
73 |
467 |
25497600 |
|
1800 |
64092195 |
vjudge1 |
D |
Nov. 2, 2019, 12:57 p.m. |
OK |
MS C++ 2017 |
TESTS |
73 |
514 |
25497600 |
|
1800 |
50565793 |
taolahung01 |
D |
Feb. 27, 2019, 1:05 p.m. |
OK |
MS C++ 2017 |
TESTS |
73 |
1278 |
34508800 |
|
1800 |
59826221 |
siwei |
D |
Aug. 31, 2019, 7:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
73 |
1419 |
47104000 |
|
1800 |
53086649 |
frederika |
D |
April 21, 2019, 9:14 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2089 |
124825600 |
|
1800 |
53115759 |
frederika |
D |
April 22, 2019, 7:53 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2120 |
134963200 |
|
1800 |
45904807 |
YESMAths |
D |
Nov. 18, 2018, 7:49 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2199 |
135475200 |
|
1800 |
53086968 |
frederika |
D |
April 21, 2019, 9:22 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2261 |
134656000 |
|
1800 |
45905346 |
YESMAths |
D |
Nov. 18, 2018, 8:05 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2401 |
133632000 |
|
1800 |
45641745 |
c1729 |
D |
Nov. 12, 2018, 8:34 p.m. |
OK |
PyPy 2 |
TESTS |
73 |
2401 |
135782400 |
|
1800 |
69866293 |
deadguy |
D |
Jan. 30, 2020, 8:34 p.m. |
OK |
PyPy 2 |
TESTS |
73 |
2402 |
134553600 |
|
1800 |
45905274 |
YESMAths |
D |
Nov. 18, 2018, 8:03 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2433 |
131891200 |
|
1800 |
45905394 |
YESMAths |
D |
Nov. 18, 2018, 8:06 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2433 |
133632000 |
|
1800 |
45905147 |
YESMAths |
D |
Nov. 18, 2018, 8 a.m. |
OK |
PyPy 2 |
TESTS |
73 |
2464 |
132300800 |
|
1800 |
69384835 |
anshuman16423 |
D |
Jan. 22, 2020, 9:31 p.m. |
OK |
Python 3 |
TESTS |
73 |
2495 |
118784000 |
|
1800 |
remove filters
Back to search problems