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"Welcome! Everything is fine. You have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity. You have a list of k pairs of people who have arrived in a new inhabited neighborhood. You need to assign each of the 2k people into one of the 2k houses. Each person will be the resident of exactly one house, and each house will have exactly one resident. Of course, in the neighborhood, it is possible to visit friends. There are 2k - 1 roads, each of which connects two houses. It takes some time to traverse a road. We will specify the amount of time it takes in the input. The neighborhood is designed in such a way that from anyone's house, there is exactly one sequence of distinct roads you can take to any other house. In other words, the graph with the houses as vertices and the roads as edges is a tree. The truth is, these k pairs of people are actually soulmates. We index them from 1 to k . We denote by f(i) the amount of time it takes for the i -th pair of soulmates to go to each other's houses. As we have said before, you will need to assign each of the 2k people into one of the 2k houses. You have two missions, one from the entities in The Good Place and one from the entities of The Bad Place. Here they are: What are the values of G and B ? The first line of input contains a single integer t ( 1 <= t <= 500 ) denoting the number of test cases. The next lines contain descriptions of the test cases. The first line of each test case contains a single integer k denoting the number of pairs of people ( 1 <= k <= 10^5 ). The next 2k - 1 lines describe the roads; the i -th of them contains three space-separated integers a_i, b_i, t_i which means that the i -th road connects the a_i -th and b_i -th houses with a road that "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
67048436 |
Frame233 |
C |
Dec. 17, 2019, 1:41 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
108 |
14745600 |
|
2000 |
67050590 |
lyzqs |
C |
Dec. 17, 2019, 3:43 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
109 |
22630400 |
|
2000 |
67047490 |
Frame233 |
C |
Dec. 17, 2019, 12:21 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
124 |
14745600 |
|
2000 |
67989800 |
poaspoas |
C |
Dec. 31, 2019, 3:33 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
124 |
17203200 |
|
2000 |
68594352 |
CTP_314 |
C |
Jan. 11, 2020, 1:36 p.m. |
OK |
GNU C++11 |
TESTS |
17 |
124 |
21606400 |
|
2000 |
67015738 |
zjczzzjczjczzzjc |
C |
Dec. 16, 2019, 11:26 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
139 |
17203200 |
|
2000 |
67070428 |
QuartZ_Z |
C |
Dec. 17, 2019, 12:34 p.m. |
OK |
GNU C++11 |
TESTS |
17 |
140 |
13926400 |
|
2000 |
68628395 |
pufanyi |
C |
Jan. 12, 2020, 12:45 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
140 |
15155200 |
|
2000 |
66912712 |
msuwakow |
C |
Dec. 15, 2019, 5:48 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
140 |
15872000 |
|
2000 |
67000697 |
hjww |
C |
Dec. 16, 2019, 5:32 a.m. |
OK |
GNU C++11 |
TESTS |
17 |
140 |
18636800 |
|
2000 |
66918302 |
disangan233 |
C |
Dec. 15, 2019, 6:11 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
186 |
39219200 |
|
2000 |
66918065 |
idxcalcal |
C |
Dec. 15, 2019, 6:10 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
264 |
40345600 |
|
2000 |
66969851 |
KisekiPurin2019 |
C |
Dec. 15, 2019, 12:53 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
374 |
10444800 |
|
2000 |
67944738 |
yyhslfw |
C |
Dec. 30, 2019, 4:31 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
389 |
15564800 |
|
2000 |
67577659 |
tsingcbx |
C |
Dec. 25, 2019, 3:52 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
390 |
21606400 |
|
2000 |
68683267 |
wucstdio |
C |
Jan. 13, 2020, 1:11 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
421 |
20992000 |
|
2000 |
66932165 |
HanZhongBalls |
C |
Dec. 15, 2019, 7:40 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
452 |
10547200 |
|
2000 |
67000964 |
nimom |
C |
Dec. 16, 2019, 5:41 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
467 |
19148800 |
|
2000 |
69053517 |
Luzivanlt |
C |
Jan. 18, 2020, 1:35 p.m. |
OK |
GNU C++14 |
TESTS |
17 |
467 |
22016000 |
|
2000 |
67466274 |
F0_0H |
C |
Dec. 23, 2019, 11:11 a.m. |
OK |
GNU C++14 |
TESTS |
17 |
467 |
22835200 |
|
2000 |
67473370 |
yosupo |
C |
Dec. 23, 2019, 1:32 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
280 |
19660800 |
|
2000 |
66926710 |
1252351876 |
C |
Dec. 15, 2019, 6:51 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
358 |
25702400 |
|
2000 |
67472107 |
solitudesky |
C |
Dec. 23, 2019, 1:09 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
374 |
15564800 |
|
2000 |
67298098 |
Phortox |
C |
Dec. 20, 2019, 5:38 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
389 |
17817600 |
|
2000 |
69025410 |
WaluntOvO |
C |
Jan. 18, 2020, 7:08 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
404 |
15564800 |
|
2000 |
66921456 |
Sinogi |
C |
Dec. 15, 2019, 6:25 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
420 |
18636800 |
|
2000 |
67138067 |
sandeep_kumar_e |
C |
Dec. 18, 2019, 5:24 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
452 |
24064000 |
|
2000 |
68055682 |
KrK |
C |
Jan. 1, 2020, 10:21 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
467 |
24166400 |
|
2000 |
66975584 |
GaryMr |
C |
Dec. 15, 2019, 2:34 p.m. |
OK |
GNU C++17 |
TESTS |
17 |
467 |
24166400 |
|
2000 |
66995313 |
jklepec |
C |
Dec. 16, 2019, 12:38 a.m. |
OK |
GNU C++17 |
TESTS |
17 |
467 |
24371200 |
|
2000 |
68324934 |
serafimkoo |
C |
Jan. 6, 2020, 4:29 p.m. |
OK |
Java 11 |
TESTS |
17 |
1419 |
193945600 |
|
2000 |
66925671 |
yuya178 |
C |
Dec. 15, 2019, 6:46 a.m. |
OK |
Java 11 |
TESTS |
17 |
1855 |
136806400 |
|
2000 |
68690632 |
zhanyi_xiaolu |
C |
Jan. 13, 2020, 5:57 a.m. |
OK |
Java 11 |
TESTS |
17 |
2090 |
98918400 |
|
2000 |
67054454 |
StayAwayFromBitches |
C |
Dec. 17, 2019, 6:07 a.m. |
OK |
Java 8 |
TESTS |
17 |
623 |
52940800 |
|
2000 |
66924826 |
nikolay.v.mikhaylov |
C |
Dec. 15, 2019, 6:41 a.m. |
OK |
Java 8 |
TESTS |
17 |
888 |
30720000 |
|
2000 |
66920326 |
icpc_loser |
C |
Dec. 15, 2019, 6:20 a.m. |
OK |
Java 8 |
TESTS |
17 |
1013 |
100044800 |
|
2000 |
66911942 |
Taran_1407 |
C |
Dec. 15, 2019, 5:45 a.m. |
OK |
Java 8 |
TESTS |
17 |
1138 |
130764800 |
|
2000 |
66926799 |
tanzaku |
C |
Dec. 15, 2019, 6:51 a.m. |
OK |
Java 8 |
TESTS |
17 |
1154 |
75366400 |
|
2000 |
67276045 |
yaoct |
C |
Dec. 20, 2019, 10:15 a.m. |
OK |
Java 8 |
TESTS |
17 |
1184 |
55603200 |
|
2000 |
68373210 |
barakraganosungam |
C |
Jan. 7, 2020, 6:31 p.m. |
OK |
Java 8 |
TESTS |
17 |
1232 |
130048000 |
|
2000 |
66983621 |
Harpae |
C |
Dec. 15, 2019, 5:17 p.m. |
OK |
Java 8 |
TESTS |
17 |
1310 |
59801600 |
|
2000 |
68424580 |
vktennis |
C |
Jan. 9, 2020, 2:06 a.m. |
OK |
Java 8 |
TESTS |
17 |
1388 |
50073600 |
|
2000 |
67175275 |
Megabyte |
C |
Dec. 18, 2019, 6:57 p.m. |
OK |
Java 8 |
TESTS |
17 |
1419 |
53862400 |
|
2000 |
68884167 |
Tlatoani |
C |
Jan. 15, 2020, 8:14 p.m. |
OK |
Kotlin |
TESTS |
17 |
2246 |
89292800 |
|
2000 |
67194359 |
Wang123123 |
C |
Dec. 19, 2019, 8:25 a.m. |
OK |
MS C++ |
TESTS |
17 |
249 |
22118400 |
|
2000 |
67194733 |
Wang123123 |
C |
Dec. 19, 2019, 8:34 a.m. |
OK |
MS C++ |
TESTS |
17 |
265 |
22118400 |
|
2000 |
66913165 |
Apsara |
C |
Dec. 15, 2019, 5:50 a.m. |
OK |
MS C++ |
TESTS |
17 |
311 |
10956800 |
|
2000 |
66915924 |
LoneFox |
C |
Dec. 15, 2019, 6 a.m. |
OK |
MS C++ |
TESTS |
17 |
717 |
19968000 |
|
2000 |
68667350 |
AleksanderBalobanov |
C |
Jan. 12, 2020, 3:36 p.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
561 |
32051200 |
|
2000 |
68666916 |
AleksanderBalobanov |
C |
Jan. 12, 2020, 3:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
639 |
39424000 |
|
2000 |
67051081 |
pichulia |
C |
Dec. 17, 2019, 4:06 a.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
701 |
25600000 |
|
2000 |
66928845 |
nukeykt |
C |
Dec. 15, 2019, 7 a.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
795 |
32972800 |
|
2000 |
67255726 |
vpike |
C |
Dec. 19, 2019, 9:57 p.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
1606 |
18329600 |
|
2000 |
67514841 |
forestlightelf |
C |
Dec. 24, 2019, 10:27 a.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
1622 |
19251200 |
|
2000 |
68038756 |
MT_07 |
C |
Jan. 1, 2020, 1:20 p.m. |
OK |
MS C++ 2017 |
TESTS |
17 |
1669 |
15872000 |
|
2000 |
69512633 |
anshuman16423 |
C |
Jan. 25, 2020, 10:58 a.m. |
OK |
PyPy 2 |
TESTS |
17 |
2432 |
72908800 |
|
2000 |
67497276 |
19n1900011773 |
C |
Dec. 24, 2019, 12:27 a.m. |
OK |
PyPy 3 |
TESTS |
17 |
2558 |
106188800 |
|
2000 |
67047645 |
tycyd |
C |
Dec. 17, 2019, 12:35 a.m. |
OK |
PyPy 3 |
TESTS |
17 |
2932 |
135782400 |
|
2000 |
67055015 |
auouo |
C |
Dec. 17, 2019, 6:23 a.m. |
OK |
PyPy 3 |
TESTS |
17 |
2979 |
106496000 |
|
2000 |
66916325 |
sansen |
C |
Dec. 15, 2019, 6:02 a.m. |
OK |
Rust |
TESTS |
17 |
405 |
35840000 |
|
2000 |
remove filters
Back to search problems