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"After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once. Vitaly was wondering how to solve the following problem. You are given an undirected graph consisting of n vertices and m edges, not necessarily connected, without parallel edges and loops. You need to find t -- the minimum number of edges that must be added to the given graph in order to form a simple cycle of an odd length, consisting of more than one vertex. Moreover, he must find w -- the number of ways to add t edges in order to form a cycle of an odd length (consisting of more than one vertex). It is prohibited to add loops or parallel edges. Two ways to add edges to the graph are considered equal if they have the same sets of added edges. Since Vitaly does not study at the university, he asked you to help him with this task. The first line of the input contains two integers n and m ( -- the number of vertices in the graph and the number of edges in the graph. Next m lines contain the descriptions of the edges of the graph, one edge per line. Each edge is given by a pair of integers ai, bi (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai, xe2 x80 x89bi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n) -- the vertices that are connected by the i-th edge. All numbers in the lines are separated by a single space. It is guaranteed that the given graph doesn't contain any loops and parallel edges. The graph isn't necessarily connected. Print in the first line of the output two space-separated integers t and w -- the minimum number of edges that should be added to the graph to form a simple cycle of an odd length consisting of more than one vertex where each vertex occurs at most once, and the number of ways to do this. The simple cycle is a cycle that doesn't contain any vertex twice."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
13337524 |
vjudge5 |
D |
Oct. 2, 2015, 1:21 a.m. |
OK |
FPC |
TESTS |
50 |
46 |
4505600 |
|
2300 |
11934013 |
CMSwift |
D |
July 5, 2015, 10:53 a.m. |
OK |
FPC |
TESTS |
50 |
46 |
5017600 |
|
2300 |
12109791 |
Gray_58 |
D |
July 18, 2015, 6:38 p.m. |
OK |
FPC |
TESTS |
50 |
46 |
13619200 |
|
2300 |
11883186 |
qjc98 |
D |
July 1, 2015, 2:04 p.m. |
OK |
FPC |
TESTS |
50 |
46 |
56115200 |
|
2300 |
11898759 |
igdor99 |
D |
July 2, 2015, 2:35 p.m. |
OK |
FPC |
TESTS |
50 |
61 |
13312000 |
|
2300 |
12314396 |
Kleaschev_Maksim |
D |
Aug. 2, 2015, 11:57 a.m. |
OK |
FPC |
TESTS |
50 |
61 |
33792000 |
|
2300 |
12522835 |
Who1 |
D |
Aug. 14, 2015, 4:48 a.m. |
OK |
GNU C |
TESTS |
50 |
46 |
6860800 |
|
2300 |
12523159 |
Who1 |
D |
Aug. 14, 2015, 5:17 a.m. |
OK |
GNU C |
TESTS |
50 |
46 |
7168000 |
|
2300 |
12011848 |
Semarapura |
D |
July 11, 2015, 6:57 p.m. |
OK |
GNU C |
TESTS |
50 |
46 |
9011200 |
|
2300 |
11866840 |
Chipe1 |
D |
June 30, 2015, 5:24 p.m. |
OK |
GNU C |
TESTS |
50 |
62 |
8704000 |
|
2300 |
11899124 |
sanketM |
D |
July 2, 2015, 3:06 p.m. |
OK |
GNU C |
TESTS |
50 |
62 |
9011200 |
|
2300 |
14023168 |
Lightning34 |
D |
Nov. 2, 2015, 12:55 p.m. |
OK |
GNU C++ |
TESTS |
50 |
15 |
6041600 |
|
2300 |
30245855 |
hyj542682306 |
D |
Sept. 10, 2017, 1:10 p.m. |
OK |
GNU C++ |
TESTS |
50 |
30 |
5017600 |
|
2300 |
12025725 |
King_George |
D |
July 13, 2015, 6:10 a.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
2867200 |
|
2300 |
12319374 |
mdwudier |
D |
Aug. 3, 2015, 12:26 a.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
3788800 |
|
2300 |
40986395 |
ReaLNero1 |
D |
July 30, 2018, 8:32 p.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
5017600 |
|
2300 |
12030533 |
love2_LH |
D |
July 13, 2015, 2:46 p.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
6246400 |
|
2300 |
13887589 |
130705009 |
D |
Oct. 27, 2015, 9:09 a.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
7168000 |
|
2300 |
20435177 |
czllgzmzl |
D |
Sept. 7, 2016, 12:11 p.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
7577600 |
|
2300 |
12906622 |
kimbbakar |
D |
Sept. 9, 2015, 7:57 a.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
8396800 |
|
2300 |
12016702 |
jugal_sahu |
D |
July 12, 2015, 8:29 a.m. |
OK |
GNU C++ |
TESTS |
50 |
31 |
8499200 |
|
2300 |
60394897 |
rainboy |
D |
Sept. 11, 2019, 2:34 p.m. |
OK |
GNU C11 |
TESTS |
50 |
46 |
6041600 |
|
2300 |
43877126 |
ouqingliang |
D |
Oct. 6, 2018, 2:40 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
6348800 |
|
2300 |
43877142 |
vjudge1 |
D |
Oct. 6, 2018, 2:41 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
6451200 |
|
2300 |
41398727 |
Jhamra |
D |
Aug. 9, 2018, 12:29 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
6656000 |
|
2300 |
12332474 |
woyeshizuile |
D |
Aug. 4, 2015, 2:46 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
7168000 |
|
2300 |
12207861 |
Duxar |
D |
July 24, 2015, 3:09 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
7680000 |
|
2300 |
17823218 |
_dne |
D |
May 9, 2016, 5:02 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
8089600 |
|
2300 |
14935282 |
heheniyilian |
D |
Dec. 23, 2015, 8:29 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
8806400 |
|
2300 |
25106303 |
FISHTOBY |
D |
Feb. 28, 2017, 5:10 p.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
10444800 |
|
2300 |
12542636 |
abandon |
D |
Aug. 15, 2015, 7:22 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
13414400 |
|
2300 |
17502552 |
UoA_ZQC |
D |
April 25, 2016, 4:20 a.m. |
OK |
GNU C++11 |
TESTS |
50 |
31 |
14643200 |
|
2300 |
21636067 |
Xin-Jie |
D |
Oct. 21, 2016, 8:09 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
5939200 |
|
2300 |
30095697 |
MiHon |
D |
Sept. 5, 2017, 9:38 a.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
7065600 |
|
2300 |
27724496 |
3_Problems_Everyday |
D |
June 11, 2017, 4:54 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
8704000 |
|
2300 |
28305085 |
Wuxing |
D |
July 5, 2017, 1:32 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
10342400 |
|
2300 |
34613338 |
vjudge1 |
D |
Jan. 27, 2018, 5:37 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
10444800 |
|
2300 |
30667616 |
topke |
D |
Sept. 24, 2017, 2:05 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
10752000 |
|
2300 |
25169928 |
mengxiang000 |
D |
March 3, 2017, 12:27 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
11673600 |
|
2300 |
34718173 |
vjudge3 |
D |
Jan. 30, 2018, 6:17 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
11776000 |
|
2300 |
34608816 |
NullByte |
D |
Jan. 27, 2018, 2:41 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
14028800 |
|
2300 |
30686789 |
topke |
D |
Sept. 24, 2017, 5:25 p.m. |
OK |
GNU C++14 |
TESTS |
50 |
46 |
16588800 |
|
2300 |
41604110 |
vjudge1 |
D |
Aug. 15, 2018, 12:01 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
31 |
7168000 |
|
2300 |
37284711 |
Hope_amasser |
D |
April 13, 2018, 12:53 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
46 |
10035200 |
|
2300 |
62588354 |
AmanGupta_ |
D |
Oct. 14, 2019, 7:47 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
4198400 |
|
2300 |
68140804 |
wladw |
D |
Jan. 3, 2020, 10:15 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
4300800 |
|
2300 |
65663619 |
yangyuchen |
D |
Nov. 24, 2019, 1:23 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
6553600 |
|
2300 |
65934064 |
Bohun |
D |
Nov. 28, 2019, 11:52 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
6963200 |
|
2300 |
63979064 |
ivan100sic |
D |
Nov. 1, 2019, 9:34 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
7577600 |
|
2300 |
66161335 |
lrvideckis |
D |
Dec. 2, 2019, 4:43 a.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
8601600 |
|
2300 |
62882746 |
Mohammad_Amin |
D |
Oct. 18, 2019, 5:18 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
8601600 |
|
2300 |
59898904 |
PouyaNavid |
D |
Sept. 2, 2019, 1:02 p.m. |
OK |
GNU C++17 |
TESTS |
50 |
62 |
8704000 |
|
2300 |
11867528 |
Sumeet.Varma |
D |
June 30, 2015, 5:34 p.m. |
OK |
Java 7 |
TESTS |
50 |
108 |
7270400 |
|
2300 |
12394847 |
tyuan73 |
D |
Aug. 6, 2015, 10:15 p.m. |
OK |
Java 7 |
TESTS |
50 |
139 |
20172800 |
|
2300 |
11872543 |
tehqin |
D |
June 30, 2015, 9:51 p.m. |
OK |
Java 7 |
TESTS |
50 |
155 |
12288000 |
|
2300 |
11894212 |
mkirsche |
D |
July 2, 2015, 9:05 a.m. |
OK |
Java 7 |
TESTS |
50 |
170 |
12288000 |
|
2300 |
12420361 |
nguyenmanhphuc |
D |
Aug. 9, 2015, 2:43 a.m. |
OK |
Java 7 |
TESTS |
50 |
171 |
7270400 |
|
2300 |
11993548 |
firstfree |
D |
July 10, 2015, 6:10 a.m. |
OK |
Java 7 |
TESTS |
50 |
171 |
12288000 |
|
2300 |
12019016 |
Megabyte |
D |
July 12, 2015, 12:38 p.m. |
OK |
Java 7 |
TESTS |
50 |
171 |
19456000 |
|
2300 |
11935099 |
PrakharJain |
D |
July 5, 2015, 12:33 p.m. |
OK |
Java 7 |
TESTS |
50 |
171 |
20787200 |
|
2300 |
11885124 |
LuuNhatPhi |
D |
July 1, 2015, 4:35 p.m. |
OK |
Java 7 |
TESTS |
50 |
202 |
19660800 |
|
2300 |
11865751 |
ultraspazz |
D |
June 30, 2015, 4:52 p.m. |
OK |
Java 7 |
TESTS |
50 |
202 |
38092800 |
|
2300 |
25275783 |
RP_9 |
D |
March 5, 2017, 11:24 p.m. |
OK |
Java 8 |
TESTS |
50 |
155 |
39833600 |
|
2300 |
14299451 |
holeguma |
D |
Nov. 16, 2015, 2:44 p.m. |
OK |
Java 8 |
TESTS |
50 |
171 |
3174400 |
|
2300 |
11993288 |
hama-du |
D |
July 10, 2015, 5:34 a.m. |
OK |
Java 8 |
TESTS |
50 |
171 |
7372800 |
|
2300 |
34415732 |
vjudge5 |
D |
Jan. 21, 2018, 1:42 p.m. |
OK |
Java 8 |
TESTS |
50 |
171 |
20787200 |
|
2300 |
11877843 |
dhrumil140396 |
D |
July 1, 2015, 7:29 a.m. |
OK |
Java 8 |
TESTS |
50 |
186 |
9216000 |
|
2300 |
12161015 |
poikniok |
D |
July 22, 2015, 8:29 a.m. |
OK |
Java 8 |
TESTS |
50 |
186 |
21401600 |
|
2300 |
11931639 |
ahmed_fathy_aly |
D |
July 5, 2015, 6:41 a.m. |
OK |
Java 8 |
TESTS |
50 |
187 |
0 |
|
2300 |
40873567 |
tsumit023 |
D |
July 28, 2018, 7:27 a.m. |
OK |
Java 8 |
TESTS |
50 |
187 |
5017600 |
|
2300 |
12276590 |
Eran |
D |
July 30, 2015, 2:56 p.m. |
OK |
Java 8 |
TESTS |
50 |
187 |
7680000 |
|
2300 |
12007997 |
searcher774 |
D |
July 11, 2015, 12:11 p.m. |
OK |
Java 8 |
TESTS |
50 |
202 |
11571200 |
|
2300 |
45088768 |
tumoyakov |
D |
Oct. 30, 2018, 8:39 a.m. |
OK |
Kotlin |
TESTS |
50 |
342 |
74035200 |
|
2300 |
11982626 |
AnatolyTolstobrov |
D |
July 9, 2015, 9:25 a.m. |
OK |
MS C# |
TESTS |
50 |
77 |
13619200 |
|
2300 |
13555058 |
camypaper |
D |
Oct. 12, 2015, 7:51 a.m. |
OK |
MS C# |
TESTS |
50 |
93 |
15052800 |
|
2300 |
24732190 |
og.kostya |
D |
Feb. 17, 2017, 5:44 a.m. |
OK |
MS C# |
TESTS |
50 |
93 |
23756800 |
|
2300 |
11958566 |
not_antony |
D |
July 7, 2015, 10:04 a.m. |
OK |
MS C++ |
TESTS |
50 |
31 |
2969600 |
|
2300 |
11957573 |
anandakirtan |
D |
July 7, 2015, 8:28 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
1740800 |
|
2300 |
12273736 |
MrKaStep |
D |
July 30, 2015, 9:28 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
3584000 |
|
2300 |
11959571 |
chiyar |
D |
July 7, 2015, 11:40 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
3993600 |
|
2300 |
12078482 |
cenariusxz |
D |
July 16, 2015, 5:38 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
4403200 |
|
2300 |
11946375 |
wowoto9772 |
D |
July 6, 2015, 10:35 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
6246400 |
|
2300 |
15437233 |
pseudo |
D |
Jan. 19, 2016, 8:34 a.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
6451200 |
|
2300 |
11898921 |
innok96 |
D |
July 2, 2015, 2:48 p.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
6758400 |
|
2300 |
12022652 |
Storminteacup |
D |
July 12, 2015, 7:32 p.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
6860800 |
|
2300 |
11870779 |
miagkov |
D |
June 30, 2015, 7:30 p.m. |
OK |
MS C++ |
TESTS |
50 |
46 |
6860800 |
|
2300 |
55450394 |
2017gdgzoi1539 |
D |
June 11, 2019, 1:54 p.m. |
OK |
MS C++ 2017 |
TESTS |
50 |
78 |
66560000 |
|
2300 |
11884652 |
minimario |
D |
July 1, 2015, 3:53 p.m. |
OK |
PyPy 3 |
TESTS |
50 |
998 |
12185600 |
|
2300 |
12348639 |
JohStraat |
D |
Aug. 5, 2015, 8:48 a.m. |
OK |
Python 2 |
TESTS |
50 |
436 |
10137600 |
|
2300 |
11901287 |
allanyin |
D |
July 2, 2015, 6:38 p.m. |
OK |
Python 2 |
TESTS |
50 |
701 |
5529600 |
|
2300 |
11874444 |
rpy3cpp |
D |
July 1, 2015, 2:03 a.m. |
OK |
Python 3 |
TESTS |
50 |
514 |
10649600 |
|
2300 |
11886854 |
achulkov2 |
D |
July 1, 2015, 7:18 p.m. |
OK |
Python 3 |
TESTS |
50 |
670 |
134451200 |
|
2300 |
15261645 |
cugel |
D |
Jan. 8, 2016, 11:01 p.m. |
OK |
Python 3 |
TESTS |
50 |
686 |
15769600 |
|
2300 |
remove filters
Back to search problems