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'There is a straight line colored in white. n black segments are added on it one by one. After each segment is added, determine the number of connected components of black segments (i. e. the number of black segments in the union of the black segments). In particular, if one segment ends in a point x, and another segment starts in the point x, these two segments belong to the same connected component. The first line contains a single integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89200 xe2 x80 x89000) -- the number of segments. The i-th of the next n lines contains two integers li and ri (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89li xe2 x80 x89< xe2 x80 x89ri xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) -- the coordinates of the left and the right ends of the i-th segment. The segments are listed in the order they are added on the white line. Print n integers -- the number of connected components of black segments after each segment is added. In the first example there are two components after the addition of the first two segments, because these segments do not intersect. The third added segment intersects the left segment and touches the right segment at the point 4 (these segments belong to the same component, according to the statements). Thus the number of connected components of black segments is equal to 1 after that. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
36682405 |
panyuchao |
J |
March 28, 2018, 3:32 a.m. |
OK |
GNU C++ |
TESTS |
46 |
296 |
9932800 |
|
2500 |
54505593 |
WOSHIGEPACHONG2 |
J |
May 23, 2019, 3:28 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
124 |
6451200 |
|
2500 |
58198437 |
dyxg |
J |
Aug. 3, 2019, 2:28 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
140 |
6451200 |
|
2500 |
56028624 |
time_interspace |
J |
June 25, 2019, 8:20 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
140 |
6451200 |
|
2500 |
53956448 |
time_interspace |
J |
May 10, 2019, 12:05 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
156 |
6451200 |
|
2500 |
58208795 |
lohannes |
J |
Aug. 3, 2019, 8:07 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
171 |
6451200 |
|
2500 |
58198978 |
Fubuki |
J |
Aug. 3, 2019, 2:50 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
171 |
6451200 |
|
2500 |
58207874 |
imily |
J |
Aug. 3, 2019, 7:46 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
202 |
6451200 |
|
2500 |
52301986 |
zck |
J |
April 4, 2019, 9:46 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
202 |
6451200 |
|
2500 |
58208564 |
imily |
J |
Aug. 3, 2019, 8:02 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
218 |
6451200 |
|
2500 |
57870628 |
lopare |
J |
July 28, 2019, 1:26 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
233 |
6451200 |
|
2500 |
47863006 |
fish-porridge |
J |
Jan. 3, 2019, 7:39 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
217 |
6553600 |
|
2500 |
60777474 |
tunni46 |
J |
Sept. 18, 2019, 2:58 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
233 |
6553600 |
|
2500 |
37681972 |
4l5n3 |
J |
April 28, 2018, 10:02 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
234 |
9932800 |
|
2500 |
36364924 |
LoDThe DarkKeks |
J |
March 17, 2018, 5:01 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
264 |
9932800 |
|
2500 |
37042460 |
jslijin |
J |
April 7, 2018, 7:52 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
265 |
9932800 |
|
2500 |
36368671 |
Darui99 |
J |
March 17, 2018, 6:17 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
265 |
9932800 |
|
2500 |
67193784 |
frost_ |
J |
Dec. 19, 2019, 8:13 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
280 |
6553600 |
|
2500 |
42894244 |
w446506278 |
J |
Sept. 15, 2018, 2:36 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
280 |
6553600 |
|
2500 |
37681930 |
4l5n3 |
J |
April 28, 2018, 9:59 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
280 |
9932800 |
|
2500 |
36366400 |
taxicoo |
J |
March 17, 2018, 5:22 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
280 |
9932800 |
|
2500 |
62388385 |
Anachor |
J |
Oct. 11, 2019, 11:11 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
248 |
6553600 |
|
2500 |
69877681 |
segmentfault |
J |
Jan. 31, 2020, 4:57 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
249 |
6553600 |
|
2500 |
36361003 |
Alexxx unreal.eugene |
J |
March 17, 2018, 4:13 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
264 |
9932800 |
|
2500 |
36371915 |
I_Love_Tina |
J |
March 17, 2018, 9:20 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
280 |
9932800 |
|
2500 |
40006500 |
Scampish Valentin_E |
J |
July 5, 2018, 6:39 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
373 |
10649600 |
|
2500 |
51819354 |
Peasant |
J |
March 25, 2019, 11:13 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
623 |
198348800 |
|
2500 |
36756333 |
Teewar |
J |
March 30, 2018, 6:28 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
624 |
9932800 |
|
2500 |
36400908 |
Lollipop |
J |
March 19, 2018, 12:22 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
701 |
9932800 |
|
2500 |
36361902 |
dani_bw TaTaPiH |
J |
March 17, 2018, 4:24 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
732 |
9932800 |
|
2500 |
62419748 |
Sukarna_Paul |
J |
Oct. 12, 2019, 12:35 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
733 |
41881600 |
|
2500 |
36518840 |
sungodavi |
J |
March 23, 2018, 2:40 a.m. |
OK |
Java 8 |
TESTS |
46 |
592 |
26726400 |
|
2500 |
remove filters
Back to search problems