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 hard version, 2 <= q sum n <= q 10^5 and 1 <= q sum m <= q 5 x 10^{5} 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 <= q 10^5 ) -- the number of test cas"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
262140454 |
include_c |
G3 |
May 22, 2024, 11:58 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
41 |
1077 |
24166400 |
|
2400 |
259507592 |
Gamal74 |
G3 |
May 4, 2024, 12:27 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
40 |
421 |
16896000 |
|
2400 |
260050703 |
theRealChainman |
G3 |
May 8, 2024, 9:38 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
421 |
22220800 |
|
2400 |
260590178 |
janY_ |
G3 |
May 11, 2024, 10:20 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
436 |
20275200 |
|
2400 |
263160443 |
Kirill22 |
G3 |
May 29, 2024, 3:08 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
468 |
17510400 |
|
2400 |
261565691 |
new_Sheth_Atitya |
G3 |
May 18, 2024, 5:45 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
468 |
27238400 |
|
2400 |
259505739 |
TripleM5da |
G3 |
May 4, 2024, 12:11 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
40 |
483 |
31129600 |
|
2400 |
262178659 |
AverageAmogusEnjoyer |
G3 |
May 22, 2024, 5:46 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
484 |
14745600 |
|
2400 |
261565446 |
new_Sheth_Atitya |
G3 |
May 18, 2024, 5:43 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
499 |
27136000 |
|
2400 |
262179724 |
AverageAmogusEnjoyer |
G3 |
May 22, 2024, 5:56 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
515 |
14643200 |
|
2400 |
262427566 |
Lambd47 |
G3 |
May 24, 2024, 6:47 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
41 |
531 |
14950400 |
|
2400 |
260715762 |
Tanzir_13 |
G3 |
May 12, 2024, 9:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
265 |
22937600 |
|
2400 |
262419285 |
NotFound |
G3 |
May 24, 2024, 5:23 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
343 |
34099200 |
|
2400 |
260894058 |
taitaisama |
G3 |
May 14, 2024, 7:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
358 |
32153600 |
|
2400 |
259749109 |
nkamzabek |
G3 |
May 6, 2024, 12:33 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
359 |
32358400 |
|
2400 |
259507558 |
Gamal74 |
G3 |
May 4, 2024, 12:27 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
40 |
374 |
23654400 |
|
2400 |
259705955 |
_Rise |
G3 |
May 6, 2024, 5:18 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
374 |
42291200 |
|
2400 |
261005443 |
Fortran_must_add_too |
G3 |
May 15, 2024, 5:22 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
374 |
49356800 |
|
2400 |
261005479 |
Fortran_must_add_too |
G3 |
May 15, 2024, 5:23 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
374 |
49561600 |
|
2400 |
259645314 |
Kawaii |
G3 |
May 5, 2024, 2:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
40 |
390 |
24780800 |
|
2400 |
259993354 |
dimachine |
G3 |
May 8, 2024, 11:54 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
41 |
390 |
32256000 |
|
2400 |
259536702 |
dzhi |
G3 |
May 4, 2024, 4:42 p.m. |
OK |
Java 21 |
TESTS |
40 |
1249 |
77824000 |
|
2400 |
259532672 |
dzhi |
G3 |
May 4, 2024, 4:06 p.m. |
OK |
Java 21 |
TESTS |
40 |
1281 |
77926400 |
|
2400 |
259496724 |
arvindf232 |
G3 |
May 4, 2024, 10:59 a.m. |
OK |
Kotlin 1.7 |
TESTS |
40 |
1124 |
188825600 |
|
2400 |
259496708 |
arvindf232 |
G3 |
May 4, 2024, 10:58 a.m. |
OK |
Kotlin 1.7 |
TESTS |
40 |
1171 |
164761600 |
|
2400 |
260066884 |
BetterThanNobita |
G3 |
May 9, 2024, 3:54 a.m. |
OK |
Rust 2021 |
TESTS |
41 |
499 |
45158400 |
|
2400 |
260066560 |
BetterThanNobita |
G3 |
May 9, 2024, 3:48 a.m. |
OK |
Rust 2021 |
TESTS |
41 |
500 |
45158400 |
|
2400 |
260066488 |
BetterThanNobita |
G3 |
May 9, 2024, 3:46 a.m. |
OK |
Rust 2021 |
TESTS |
41 |
578 |
45158400 |
|
2400 |
remove filters
Back to search problems