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 graph of n vertices indexed from 1 to n , where vertex i has a value a_i assigned to it and all values a_i are different. There is an edge between two vertices u and v if either a_u divides a_v or a_v divides a_u . Find the minimum number of vertices to remove such that the remaining graph is bipartite, when you remove a vertex you remove all the edges incident to it. The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 5 cdot10^4 ) -- the number of vertices in the graph. The second line of each test case contains n integers, the i -th of them is the value a_i ( 1 <= a_i <= 5 cdot10^4 ) assigned to the i -th vertex, all values a_i are different. It is guaranteed that the sum of n over all test cases does not exceed 5 cdot10^4 . For each test case print a single integer -- the minimum number of vertices to remove such that the remaining graph is bipartite. In the first test case if we remove the vertices with values 1 and 2 we will obtain a bipartite graph, so the answer is 2 , it is impossible to remove less than 2 vertices and still obtain a bipartite graph. In the second test case we do not have to remove any vertex because the graph is already bipartite, so the answer is 0 . In the third test case we only have to remove the vertex with value 12 , so the answer is 1 . In the fourth test case we remove the vertices with values 2 and 195 , so the answer is 2 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
144270330 |
BhaskarTM |
F |
Jan. 28, 2022, 12:47 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
311 |
33075200 |
|
|
144280636 |
eecs |
F |
Jan. 28, 2022, 4:43 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
358 |
75059200 |
|
|
144279316 |
eecs |
F |
Jan. 28, 2022, 4:22 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
420 |
88780800 |
|
|
144282911 |
sp40016 |
F |
Jan. 28, 2022, 5:16 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
140 |
22016000 |
|
|
144263549 |
hamza.faidi |
F |
Jan. 27, 2022, 8:31 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
140 |
22016000 |
|
|
144262146 |
Marcin_smu |
F |
Jan. 27, 2022, 8:03 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
155 |
24473600 |
|
|
144277894 |
Alan233 |
F |
Jan. 28, 2022, 3:58 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
373 |
100864000 |
|
|
144242088 |
Radewoosh |
F |
Jan. 27, 2022, 4:22 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
624 |
114995200 |
|
|
144246407 |
Miracle0viiiiiv |
F |
Jan. 27, 2022, 4:31 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
685 |
42905600 |
|
|
144271801 |
CQXYM |
F |
Jan. 28, 2022, 1:42 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
779 |
97689600 |
|
|
144286198 |
ttklwxx |
F |
Jan. 28, 2022, 5:58 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
811 |
98099200 |
|
|
144210863 |
Um_nik |
F |
Jan. 27, 2022, 3:23 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
966 |
97689600 |
|
|
144270059 |
barkat03 |
F |
Jan. 28, 2022, 12:34 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
1028 |
117862400 |
|
|
144263948 |
prateek_tripathi |
F |
Jan. 27, 2022, 8:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
124 |
26316800 |
|
|
144254936 |
jtnydv25 |
F |
Jan. 27, 2022, 6:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
124 |
26316800 |
|
|
144259720 |
ecnerwala |
F |
Jan. 27, 2022, 7:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
156 |
20377600 |
|
|
144255940 |
Benq |
F |
Jan. 27, 2022, 6:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
420 |
77516800 |
|
|
144284701 |
ynycoding |
F |
Jan. 28, 2022, 5:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
639 |
75980800 |
|
|
144244711 |
maroonrk |
F |
Jan. 27, 2022, 4:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
670 |
82124800 |
|
|
144265939 |
pakhandi98 |
F |
Jan. 27, 2022, 9:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
841 |
128819200 |
|
|
144278162 |
wygzgyw |
F |
Jan. 28, 2022, 4:03 a.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
1403 |
101683200 |
|
|
144256695 |
wangziji |
F |
Jan. 27, 2022, 6:52 p.m. |
OK |
GNU C++17 (64) |
TESTS |
42 |
2932 |
345292800 |
|
|
144237561 |
ksun48 |
F |
Jan. 27, 2022, 4:12 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
109 |
28672000 |
|
|
144255845 |
jyothirmai01 |
F |
Jan. 27, 2022, 6:45 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
280 |
73318400 |
|
|
144254842 |
nor |
F |
Jan. 27, 2022, 6:35 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
296 |
73318400 |
|
|
144254707 |
Elegia |
F |
Jan. 27, 2022, 6:34 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
311 |
58368000 |
|
|
144254188 |
nor |
F |
Jan. 27, 2022, 6:32 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
327 |
68710400 |
|
|
144239829 |
heno239 |
F |
Jan. 27, 2022, 4:17 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
436 |
102707200 |
|
|
144246802 |
Vercingetorix |
F |
Jan. 27, 2022, 4:32 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
483 |
53350400 |
|
|
144255927 |
jiangly |
F |
Jan. 27, 2022, 6:46 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
655 |
77926400 |
|
|
144244456 |
mhq |
F |
Jan. 27, 2022, 4:27 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
794 |
126668800 |
|
|
144257129 |
flowerletter |
F |
Jan. 27, 2022, 6:56 p.m. |
OK |
GNU C++20 (64) |
TESTS |
42 |
1949 |
125440000 |
|
|
remove filters
Back to search problems