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"There are n cities and m bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter w . You can travel through the roads, but the government made a new law: you can only go through two roads at a time (go from city a to city b and then from city b to city c ) and you will have to pay (w_{ab} + w_{bc})^2 money to go through those roads. Find out whether it is possible to travel from city 1 to every other city t and what's the minimum amount of money you need to get from 1 to t . First line contains two integers n , m ( 2 <= q n <= q 10^5 , 1 <= q m <= q min( frac{n cdot (n - 1)}{2}, 2 cdot 10^5) ). Next m lines each contain three integers v_i , u_i , w_i ( 1 <= q v_i, u_i <= q n , 1 <= q w_i <= q 50 , u_i neq v_i ). It's guaranteed that there are no multiple edges, i.e. for any edge (u_i, v_i) there are no other edges (u_i, v_i) or (v_i, u_i) . For every city t print one integer. If there is no correct path between 1 and t output -1 . Otherwise print out the minimum amount of money needed to travel from 1 to t . The graph in the first example looks like this. In the second example the path from 1 to 3 goes through 2 , so the resulting payment is (1 + 2)^2 = 9 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
107906229 |
NamelessOIer |
E |
Feb. 19, 2021, 5:15 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
186 |
12902400 |
|
|
107903326 |
Dreamfarer |
E |
Feb. 19, 2021, 4:37 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
187 |
12390400 |
|
|
107907139 |
TrivialMan |
E |
Feb. 19, 2021, 5:27 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
234 |
12902400 |
|
|
107892326 |
sexyAKking |
E |
Feb. 19, 2021, 12:36 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
249 |
22937600 |
|
|
107906022 |
iyua |
E |
Feb. 19, 2021, 5:13 a.m. |
OK |
GNU C++11 |
TESTS |
83 |
374 |
68403200 |
|
|
107871272 |
usuyus |
E |
Feb. 18, 2021, 5:49 p.m. |
OK |
GNU C++11 |
TESTS |
66 |
436 |
43212800 |
|
|
107893461 |
sky123 |
E |
Feb. 19, 2021, 1:17 a.m. |
OK |
GNU C++11 |
TESTS |
78 |
436 |
70144000 |
|
|
107890029 |
lunchbox |
E |
Feb. 18, 2021, 10:56 p.m. |
OK |
GNU C++11 |
TESTS |
78 |
452 |
72396800 |
|
|
107890226 |
tykkipeli |
E |
Feb. 18, 2021, 11:02 p.m. |
OK |
GNU C++11 |
TESTS |
78 |
467 |
41267200 |
|
|
107899667 |
noob1918 |
E |
Feb. 19, 2021, 3:39 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
467 |
77824000 |
|
|
107908179 |
rwbywhite |
E |
Feb. 19, 2021, 5:40 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
234 |
23142400 |
|
|
107875094 |
10-chan |
E |
Feb. 18, 2021, 6:18 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
265 |
11980800 |
|
|
107869460 |
krishrawat |
E |
Feb. 18, 2021, 5:42 p.m. |
OK |
GNU C++14 |
TESTS |
61 |
343 |
22528000 |
|
|
107898731 |
wzyeustia |
E |
Feb. 19, 2021, 3:23 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
343 |
24473600 |
|
|
107882410 |
_no0B |
E |
Feb. 18, 2021, 7:46 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
405 |
45772800 |
|
|
107901704 |
farmerboy |
E |
Feb. 19, 2021, 4:14 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
452 |
63692800 |
|
|
107888353 |
irreversible |
E |
Feb. 18, 2021, 9:56 p.m. |
OK |
GNU C++14 |
TESTS |
70 |
467 |
55603200 |
|
|
107904520 |
Xetrazeus |
E |
Feb. 19, 2021, 4:53 a.m. |
OK |
GNU C++14 |
TESTS |
83 |
467 |
68812800 |
|
|
107892524 |
Samaun |
E |
Feb. 19, 2021, 12:44 a.m. |
OK |
GNU C++14 |
TESTS |
78 |
483 |
71168000 |
|
|
107899058 |
bigdekopon |
E |
Feb. 19, 2021, 3:28 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
514 |
60928000 |
|
|
107873606 |
nor |
E |
Feb. 18, 2021, 6:06 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
249 |
12185600 |
|
|
107906572 |
Lqingyi |
E |
Feb. 19, 2021, 5:20 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
249 |
12492800 |
|
|
107907003 |
Lqingyi |
E |
Feb. 19, 2021, 5:25 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
249 |
15872000 |
|
|
107885595 |
sleepwalking643 |
E |
Feb. 18, 2021, 8:44 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
264 |
12492800 |
|
|
107887723 |
Lin2602 |
E |
Feb. 18, 2021, 9:38 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
264 |
15155200 |
|
|
107874274 |
Ji_Kuai |
E |
Feb. 18, 2021, 6:11 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
264 |
15155200 |
|
|
107901435 |
asklvd |
E |
Feb. 19, 2021, 4:09 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
280 |
20172800 |
|
|
107902716 |
wzyeustia |
E |
Feb. 19, 2021, 4:29 a.m. |
OK |
GNU C++17 |
TESTS |
83 |
280 |
24473600 |
|
|
107895000 |
arpan_goswami |
E |
Feb. 19, 2021, 2:02 a.m. |
OK |
GNU C++17 |
TESTS |
79 |
311 |
24371200 |
|
|
107879198 |
p3rfect |
E |
Feb. 18, 2021, 7:02 p.m. |
OK |
GNU C++17 |
TESTS |
70 |
327 |
13619200 |
|
|
107873937 |
nor |
E |
Feb. 18, 2021, 6:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
70 |
218 |
14540800 |
|
|
107894735 |
eyangch |
E |
Feb. 19, 2021, 1:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
79 |
218 |
16076800 |
|
|
107875040 |
nor |
E |
Feb. 18, 2021, 6:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
70 |
233 |
14540800 |
|
|
107874599 |
nor |
E |
Feb. 18, 2021, 6:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
70 |
233 |
14540800 |
|
|
107895692 |
hello_codeforces |
E |
Feb. 19, 2021, 2:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
80 |
233 |
21708800 |
|
|
107881611 |
-ILLIA- |
E |
Feb. 18, 2021, 7:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
70 |
264 |
18534400 |
|
|
107898097 |
inszva |
E |
Feb. 19, 2021, 3:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
82 |
265 |
26828800 |
|
|
107890745 |
verigo |
E |
Feb. 18, 2021, 11:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
78 |
280 |
39116800 |
|
|
107895634 |
zlt1117 |
E |
Feb. 19, 2021, 2:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
80 |
280 |
67686400 |
|
|
107869453 |
hello_codeforces |
E |
Feb. 18, 2021, 5:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
61 |
327 |
61644800 |
|
|
107900155 |
0x3F |
E |
Feb. 19, 2021, 3:47 a.m. |
OK |
Go |
TESTS |
83 |
296 |
31334400 |
|
|
107900109 |
0x3F |
E |
Feb. 19, 2021, 3:46 a.m. |
OK |
Go |
TESTS |
83 |
499 |
31334400 |
|
|
107895274 |
Ahmed_Hosssam |
E |
Feb. 19, 2021, 2:09 a.m. |
OK |
Java 11 |
TESTS |
79 |
998 |
57344000 |
|
|
107879855 |
Dukkha |
E |
Feb. 18, 2021, 7:10 p.m. |
OK |
Java 11 |
TESTS |
70 |
1372 |
89497600 |
|
|
107895021 |
Ahmed_Hosssam |
E |
Feb. 19, 2021, 2:02 a.m. |
OK |
Java 11 |
TESTS |
79 |
1482 |
131481600 |
|
|
107882908 |
Khater |
E |
Feb. 18, 2021, 7:54 p.m. |
OK |
Java 8 |
TESTS |
70 |
857 |
35430400 |
|
|
107890421 |
Khater |
E |
Feb. 18, 2021, 11:11 p.m. |
OK |
Java 8 |
TESTS |
78 |
982 |
35532800 |
|
|
107890476 |
Khater |
E |
Feb. 18, 2021, 11:13 p.m. |
OK |
Java 8 |
TESTS |
78 |
1153 |
70451200 |
|
|
107866899 |
pulkit1411 |
E |
Feb. 18, 2021, 4:49 p.m. |
OK |
Java 8 |
TESTS |
61 |
1403 |
135168000 |
|
|
107890505 |
Khater |
E |
Feb. 18, 2021, 11:13 p.m. |
OK |
Java 8 |
TESTS |
78 |
1528 |
133222400 |
|
|
107888370 |
martins |
E |
Feb. 18, 2021, 9:57 p.m. |
OK |
Java 8 |
TESTS |
70 |
1543 |
128102400 |
|
|
107888392 |
martins |
E |
Feb. 18, 2021, 9:57 p.m. |
OK |
Java 8 |
TESTS |
70 |
1590 |
79872000 |
|
|
107890453 |
Khater |
E |
Feb. 18, 2021, 11:12 p.m. |
OK |
Java 8 |
TESTS |
78 |
2776 |
227942400 |
|
|
107870487 |
Tlatoani |
E |
Feb. 18, 2021, 5:45 p.m. |
OK |
Kotlin |
TESTS |
62 |
1341 |
109568000 |
|
|
107881974 |
Potassium |
E |
Feb. 18, 2021, 7:39 p.m. |
OK |
Kotlin |
TESTS |
70 |
1575 |
49152000 |
|
|
107874746 |
Potassium |
E |
Feb. 18, 2021, 6:15 p.m. |
OK |
Kotlin |
TESTS |
70 |
3978 |
335769600 |
|
|
107874884 |
Potassium |
E |
Feb. 18, 2021, 6:16 p.m. |
OK |
Kotlin |
TESTS |
70 |
3993 |
318976000 |
|
|
107904583 |
VClZ |
E |
Feb. 19, 2021, 4:54 a.m. |
OK |
MS C++ 2017 |
TESTS |
83 |
1122 |
219852800 |
|
|
107894470 |
wjli |
E |
Feb. 19, 2021, 1:47 a.m. |
OK |
MS C++ 2017 |
TESTS |
79 |
2557 |
347545600 |
|
|
107888680 |
getN1ght |
E |
Feb. 18, 2021, 10:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
70 |
2683 |
40345600 |
|
|
107888997 |
getN1ght |
E |
Feb. 18, 2021, 10:18 p.m. |
OK |
MS C++ 2017 |
TESTS |
70 |
2730 |
42188800 |
|
|
107899479 |
colicon |
E |
Feb. 19, 2021, 3:36 a.m. |
OK |
PyPy 3 |
TESTS |
82 |
1574 |
64819200 |
|
|
107899116 |
colicon |
E |
Feb. 19, 2021, 3:29 a.m. |
OK |
PyPy 3 |
TESTS |
82 |
1637 |
65331200 |
|
|
107902930 |
sh1194 |
E |
Feb. 19, 2021, 4:32 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
1699 |
64819200 |
|
|
107876499 |
at_f |
E |
Feb. 18, 2021, 6:32 p.m. |
OK |
PyPy 3 |
TESTS |
70 |
2059 |
169164800 |
|
|
107888126 |
silvertint |
E |
Feb. 18, 2021, 9:49 p.m. |
OK |
PyPy 3 |
TESTS |
70 |
2074 |
132198400 |
|
|
107871321 |
tamato |
E |
Feb. 18, 2021, 5:50 p.m. |
OK |
PyPy 3 |
TESTS |
66 |
2230 |
80793600 |
|
|
107889551 |
silvertint |
E |
Feb. 18, 2021, 10:39 p.m. |
OK |
PyPy 3 |
TESTS |
78 |
2449 |
141107200 |
|
|
107883590 |
BIGMOM |
E |
Feb. 18, 2021, 8:06 p.m. |
OK |
PyPy 3 |
TESTS |
70 |
2480 |
71168000 |
|
|
107903219 |
sh1194 |
E |
Feb. 19, 2021, 4:35 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
2807 |
71065600 |
|
|
107903156 |
sh1194 |
E |
Feb. 19, 2021, 4:34 a.m. |
OK |
PyPy 3 |
TESTS |
83 |
2947 |
71270400 |
|
|
107880285 |
apilat |
E |
Feb. 18, 2021, 7:16 p.m. |
OK |
Rust |
TESTS |
70 |
1341 |
113356800 |
|
|
remove filters
Back to search problems