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"In the easy version, m = n-1 and there exists a path between u and v for all u, v ( 1 <= q u, v <= q n ). After a worker's strike organized by the Dementors asking for equal rights, the prison of Azkaban has suffered some damage. After settling the spirits, the Ministry of Magic is looking to renovate the prison to ensure that the Dementors are kept in check. The prison consists of n prison cells and m bi-directional corridors. The i^{th} corridor is from cells u_i to v_i . A subset of these cells S is called a complex if any cell in S is reachable from any other cell in S . Formally, a subset of cells S is a complex if x and y are reachable from each other for all x, y in S , using only cells from S on the way. The funding required for a complex S consisting of k cells is defined as k^2 . As part of your Intro to Magical Interior Design course at Hogwarts, you have been tasked with designing the prison. The Ministry of Magic has asked that you divide the prison into 2 complexes with textbf{exactly one corridor} connecting them, so that the Dementors can't organize union meetings. For this purpose, you are allowed to build bi-directional corridors. The funding required to build a corridor between any 2 cells is c . Due to budget cuts and the ongoing fight against the Death Eaters, you must find the textbf{minimum total funding} required to divide the prison as per the Ministry's requirements or -1 if no division is possible. Note: The total funding is the sum of the funding required for the 2 complexes and the corridors built. If after the division, the two complexes have x and y cells respectively and you have built a total of a corridors, the total funding will be x^2 + y^2 + c x a . Note that x+y=n . The first line contains one integer t ( 1 <= q t l"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
260706602 |
duyiblue |
G1 |
May 12, 2024, 7:13 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
109 |
6246400 |
|
1900 |
260105729 |
cyrong |
G1 |
May 9, 2024, 10:37 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
125 |
3993600 |
|
1900 |
262528094 |
daohuyenchi21 |
G1 |
May 25, 2024, 2:45 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
140 |
3276800 |
|
1900 |
260138319 |
Mhmd_E_Dak |
G1 |
May 9, 2024, 2:42 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
140 |
7577600 |
|
1900 |
260930367 |
granadierfc |
G1 |
May 14, 2024, 1:03 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
155 |
512000 |
|
1900 |
259501248 |
Jimanbanashi |
G1 |
May 4, 2024, 11:34 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
155 |
3276800 |
|
1900 |
259789525 |
SudhirHajare01 |
G1 |
May 6, 2024, 6:08 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
155 |
3993600 |
|
1900 |
259768666 |
domekj |
G1 |
May 6, 2024, 2:59 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
155 |
3993600 |
|
1900 |
261530309 |
hbu_jmx666 |
G1 |
May 18, 2024, 12:35 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
155 |
6553600 |
|
1900 |
261326154 |
leodicaprio4791 |
G1 |
May 17, 2024, 12:11 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
63 |
156 |
14745600 |
|
1900 |
260715876 |
Tanzir_13 |
G1 |
May 12, 2024, 9:35 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
93 |
2560000 |
|
1900 |
261717386 |
tharun_1241 |
G1 |
May 20, 2024, 3:25 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
1126400 |
|
1900 |
261549200 |
NicodingZhen |
G1 |
May 18, 2024, 3:20 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
1638400 |
|
1900 |
259930045 |
__HananSaeed__ |
G1 |
May 7, 2024, 9:52 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
1740800 |
|
1900 |
261578087 |
I_FloPPed21 |
G1 |
May 18, 2024, 8:21 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
2048000 |
|
1900 |
260712606 |
mohammadyamin |
G1 |
May 12, 2024, 8:36 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
2560000 |
|
1900 |
262891496 |
ZEro1x0 |
G1 |
May 27, 2024, 2:01 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
3993600 |
|
1900 |
259545036 |
oogerbooger |
G1 |
May 4, 2024, 6:03 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
124 |
3993600 |
|
1900 |
261326130 |
vashistha001 |
G1 |
May 17, 2024, 12:10 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
125 |
102400 |
|
1900 |
262204086 |
eysbutno |
G1 |
May 23, 2024, 12:41 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
63 |
125 |
512000 |
|
1900 |
261038603 |
Fresca |
G1 |
May 15, 2024, 10:31 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
109 |
1945600 |
|
1900 |
261991570 |
zshcf |
G1 |
May 21, 2024, 9:36 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
109 |
98611200 |
|
1900 |
262023511 |
megaxgamer |
G1 |
May 21, 2024, 1:19 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
1536000 |
|
1900 |
263700161 |
sam990 |
G1 |
June 2, 2024, 4:55 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
1740800 |
|
1900 |
260254805 |
_Kee |
G1 |
May 10, 2024, 1:13 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
1945600 |
|
1900 |
261190811 |
aryak05 kkkk1234 nandhagk1729 |
G1 |
May 16, 2024, 11:59 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
2150400 |
|
1900 |
262785940 |
kyotan |
G1 |
May 26, 2024, 5:42 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
2252800 |
|
1900 |
263676045 |
ssitaram |
G1 |
June 1, 2024, 7:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
2355200 |
|
1900 |
259589681 |
shorya1835 |
G1 |
May 5, 2024, 6:08 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
2457600 |
|
1900 |
259883470 |
Vamperox |
G1 |
May 7, 2024, 1:41 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
63 |
124 |
2457600 |
|
1900 |
260053580 |
Willump1 |
G1 |
May 8, 2024, 10:56 p.m. |
OK |
GNU C11 |
TESTS |
63 |
155 |
9625600 |
|
1900 |
261972729 |
2210080018 |
G1 |
May 21, 2024, 6:55 a.m. |
OK |
Java 21 |
TESTS |
63 |
499 |
18329600 |
|
1900 |
260865157 |
Enderbrine16 |
G1 |
May 14, 2024, 1:12 a.m. |
OK |
Java 21 |
TESTS |
63 |
515 |
17203200 |
|
1900 |
259507058 |
dzhi |
G1 |
May 4, 2024, 12:22 p.m. |
OK |
Java 21 |
TESTS |
63 |
531 |
41062400 |
|
1900 |
261596243 |
sushibob |
G1 |
May 19, 2024, 3:59 a.m. |
OK |
Java 21 |
TESTS |
63 |
546 |
18124800 |
|
1900 |
260751612 |
coderman2004 |
G1 |
May 13, 2024, 6:49 a.m. |
OK |
Java 8 |
TESTS |
63 |
390 |
14745600 |
|
1900 |
262615126 |
dgucs826 |
G1 |
May 25, 2024, 6:03 p.m. |
OK |
Java 8 |
TESTS |
63 |
390 |
15360000 |
|
1900 |
262946369 |
accelerate_nju |
G1 |
May 28, 2024, 2:11 a.m. |
OK |
PyPy 3-64 |
TESTS |
63 |
296 |
26316800 |
|
1900 |
260773060 |
Little_Sheep_Yawn |
G1 |
May 13, 2024, 9:39 a.m. |
OK |
PyPy 3-64 |
TESTS |
63 |
328 |
26214400 |
|
1900 |
259991614 |
timiss |
G1 |
May 8, 2024, 11:41 a.m. |
OK |
PyPy 3-64 |
TESTS |
63 |
343 |
26624000 |
|
1900 |
262808887 |
028 |
G1 |
May 26, 2024, 11:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
63 |
452 |
177971200 |
|
1900 |
260238552 |
aha66 |
G1 |
May 10, 2024, 10:43 a.m. |
OK |
PyPy 3-64 |
TESTS |
63 |
562 |
44544000 |
|
1900 |
260013123 |
BetterThanNobita |
G1 |
May 8, 2024, 2:30 p.m. |
OK |
Rust 2021 |
TESTS |
63 |
77 |
5427200 |
|
1900 |
263200462 |
Calvin65 |
G1 |
May 30, 2024, 5:09 a.m. |
OK |
Rust 2021 |
TESTS |
63 |
124 |
5222400 |
|
1900 |
263259078 |
M1ngXu |
G1 |
May 30, 2024, 1:54 p.m. |
OK |
Rust 2021 |
TESTS |
63 |
140 |
6144000 |
|
1900 |
259499325 |
randombernie DreadedHippy Ehijoe |
G1 |
May 4, 2024, 11:19 a.m. |
OK |
Rust 2021 |
TESTS |
63 |
171 |
8294400 |
|
1900 |
263125479 |
Calvin65 |
G1 |
May 29, 2024, 10:25 a.m. |
OK |
Rust 2021 |
TESTS |
63 |
202 |
25497600 |
|
1900 |
remove filters
Back to search problems