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 array consisting of n integers a_1 , a_2 , ..., a_n . Initially a_x = 1 , all other elements are equal to 0 . You have to perform m operations. During the i -th operation, you choose two indices c and d such that l_i <= c, d <= r_i , and swap a_c and a_d . Calculate the number of indices k such that it is possible to choose the operations so that a_k = 1 in the end. The first line contains a single integer t ( 1 <= t <= 100 ) -- the number of test cases. Then the description of t testcases follow. The first line of each test case contains three integers n , x and m ( 1 <= n <= 10^9 ; 1 <= m <= 100 ; 1 <= x <= n ). Each of next m lines contains the descriptions of the operations; the i -th line contains two integers l_i and r_i ( 1 <= l_i <= r_i <= n ). For each test case print one integer -- the number of indices k such that it is possible to choose the operations so that a_k = 1 in the end. In the first test case, it is possible to achieve a_k = 1 for every k . To do so, you may use the following operations: In the second test case, only k = 1 and k = 2 are possible answers. To achieve a_1 = 1 , you have to swap a_1 and a_1 during the second operation. To achieve a_2 = 1 , you have to swap a_1 and a_2 during the second operation. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
83442411 |
zhengfuzhe123 |
B |
June 11, 2020, 4:01 p.m. |
OK |
GNU C11 |
TESTS |
4 |
0 |
0 |
|
|
83493259 |
Israt_Jahan_Nahin |
B |
June 12, 2020, 3:17 a.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83510227 |
shuvo_14 |
B |
June 12, 2020, 8:03 a.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83540032 |
vjudge5 |
B |
June 12, 2020, 2:32 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83541487 |
Rohith01 |
B |
June 12, 2020, 2:49 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83476863 |
tasja |
B |
June 11, 2020, 7:13 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83554292 |
ShofiqurRahman |
B |
June 12, 2020, 6:18 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83554844 |
ajoydey00001 |
B |
June 12, 2020, 6:25 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83572920 |
RHasanR |
B |
June 13, 2020, 3:02 a.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83551489 |
mrashid_5919 |
B |
June 12, 2020, 5:39 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
83572891 |
yz6205 |
B |
June 13, 2020, 3:01 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83572436 |
sogrub |
B |
June 13, 2020, 2:48 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83571449 |
_shafiul |
B |
June 13, 2020, 2:17 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83571206 |
_shafiul |
B |
June 13, 2020, 2:09 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83570199 |
dongyeguiwu00 |
B |
June 13, 2020, 1:27 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83573444 |
harisaran |
B |
June 13, 2020, 3:18 a.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83545848 |
Sagebrush |
B |
June 12, 2020, 3:39 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83541554 |
tiger0132 |
B |
June 12, 2020, 2:50 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83540267 |
new_xyq |
B |
June 12, 2020, 2:35 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83538221 |
YHHxBULIATANIA |
B |
June 12, 2020, 2:12 p.m. |
OK |
GNU C++11 |
TESTS |
4 |
15 |
0 |
|
|
83547160 |
aurinegro |
B |
June 12, 2020, 3:55 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83554203 |
prem_anand |
B |
June 12, 2020, 6:17 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83554250 |
ManoharKoya |
B |
June 12, 2020, 6:17 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83559775 |
i_can_ |
B |
June 12, 2020, 7:42 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83565286 |
TrinhXuanDat2000 |
B |
June 12, 2020, 9:45 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83566289 |
toberoi79 |
B |
June 12, 2020, 10:19 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83566828 |
toberoi79 |
B |
June 12, 2020, 10:41 p.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83568559 |
N_0NY |
B |
June 13, 2020, 12:03 a.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83569784 |
Willem |
B |
June 13, 2020, 1:06 a.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83572174 |
garima_19 |
B |
June 13, 2020, 2:41 a.m. |
OK |
GNU C++14 |
TESTS |
4 |
15 |
0 |
|
|
83472442 |
a4vrlyui |
B |
June 11, 2020, 6:11 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
83460971 |
Abhigyan12 |
B |
June 11, 2020, 4:37 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
307200 |
|
|
83569946 |
yashsaga |
B |
June 13, 2020, 1:14 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83568844 |
Manchester_UNITED |
B |
June 13, 2020, 12:17 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83564521 |
montashir_fahim |
B |
June 12, 2020, 9:22 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83563762 |
Jaki |
B |
June 12, 2020, 9:03 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83570198 |
jagadeesh19 |
B |
June 13, 2020, 1:27 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83559595 |
Ernest0_0Abreu |
B |
June 12, 2020, 7:38 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83558225 |
maxovic |
B |
June 12, 2020, 7:15 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83556180 |
Ovi |
B |
June 12, 2020, 6:44 p.m. |
OK |
GNU C++17 |
TESTS |
4 |
15 |
0 |
|
|
83538234 |
AayushAC1998 |
B |
June 12, 2020, 2:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83563518 |
sanyam1101 |
B |
June 12, 2020, 8:57 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83561675 |
Geothermal |
B |
June 12, 2020, 8:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83558067 |
catismyfav |
B |
June 12, 2020, 7:12 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83557661 |
rahuliitkgp |
B |
June 12, 2020, 7:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83553539 |
Udoy_Das |
B |
June 12, 2020, 6:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83548017 |
sharatmehrotra |
B |
June 12, 2020, 4:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83529694 |
hltk |
B |
June 12, 2020, 12:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83528220 |
Bazigar |
B |
June 12, 2020, 12:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83525469 |
VeggiePaaji |
B |
June 12, 2020, 11:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
15 |
0 |
|
|
83567227 |
TimmyThinMints |
B |
June 12, 2020, 10:58 p.m. |
OK |
Java 11 |
TESTS |
4 |
155 |
0 |
|
|
83466729 |
anupamm98 |
B |
June 11, 2020, 5:11 p.m. |
OK |
Java 11 |
TESTS |
4 |
155 |
0 |
|
|
83444381 |
gaurav.mishra_ |
B |
June 11, 2020, 4:05 p.m. |
OK |
Java 11 |
TESTS |
4 |
155 |
0 |
|
|
83465129 |
snake_123 |
B |
June 11, 2020, 4:58 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83537961 |
Raj9400 |
B |
June 12, 2020, 2:09 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83528331 |
jakejase2 |
B |
June 12, 2020, 12:06 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83506513 |
bhrugu_dave |
B |
June 12, 2020, 7:12 a.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83485701 |
R3KT |
B |
June 11, 2020, 10:58 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83478513 |
vickyvanshaj |
B |
June 11, 2020, 7:42 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83458683 |
pgupta9830 |
B |
June 11, 2020, 4:32 p.m. |
OK |
Java 11 |
TESTS |
4 |
171 |
0 |
|
|
83541291 |
shojin_pro |
B |
June 12, 2020, 2:47 p.m. |
OK |
Java 8 |
TESTS |
4 |
78 |
0 |
|
|
83465760 |
NAVEEN_SINGH |
B |
June 11, 2020, 5:03 p.m. |
OK |
Java 8 |
TESTS |
4 |
92 |
0 |
|
|
83459050 |
vishu03 |
B |
June 11, 2020, 4:33 p.m. |
OK |
Java 8 |
TESTS |
4 |
92 |
0 |
|
|
83519733 |
noobie_code |
B |
June 12, 2020, 10:15 a.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83493576 |
Manan8686 |
B |
June 12, 2020, 3:23 a.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83476483 |
hars1234 |
B |
June 11, 2020, 7:07 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83474134 |
kareem3id |
B |
June 11, 2020, 6:32 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83462712 |
kunalkatiyar9 |
B |
June 11, 2020, 4:44 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83459359 |
obsessed_titan |
B |
June 11, 2020, 4:33 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83455061 |
chinmaya21 |
B |
June 11, 2020, 4:26 p.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
83445772 |
iShivansh |
B |
June 11, 2020, 4:08 p.m. |
OK |
Kotlin |
TESTS |
4 |
93 |
0 |
|
|
83486342 |
sylvyrfysh |
B |
June 11, 2020, 11:30 p.m. |
OK |
Kotlin |
TESTS |
4 |
108 |
0 |
|
|
83491132 |
Spheniscine |
B |
June 12, 2020, 2:30 a.m. |
OK |
Kotlin |
TESTS |
4 |
109 |
0 |
|
|
83448750 |
Kap_Knight |
B |
June 11, 2020, 4:14 p.m. |
OK |
Kotlin |
TESTS |
4 |
124 |
0 |
|
|
83482648 |
shivam1420 |
B |
June 11, 2020, 9:13 p.m. |
OK |
Kotlin |
TESTS |
4 |
139 |
1228800 |
|
|
83529220 |
whiter4bbit |
B |
June 12, 2020, 12:18 p.m. |
OK |
Kotlin |
TESTS |
4 |
155 |
0 |
|
|
83444992 |
ravinem1 |
B |
June 11, 2020, 4:06 p.m. |
OK |
Mono C# |
TESTS |
4 |
62 |
5427200 |
|
|
83472666 |
rawatkaran930 |
B |
June 11, 2020, 6:13 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
83467275 |
Yomapeed |
B |
June 11, 2020, 5:16 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
83442886 |
Tuenjuko |
B |
June 11, 2020, 4:02 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
30 |
0 |
|
|
83450841 |
vandartem |
B |
June 11, 2020, 4:18 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
30 |
0 |
|
|
83511537 |
qq1598852340 |
B |
June 12, 2020, 8:21 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
30 |
0 |
|
|
83488052 |
IronicNinja |
B |
June 12, 2020, 12:43 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
30 |
0 |
|
|
83468281 |
gbanuel3 |
B |
June 11, 2020, 5:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
30 |
0 |
|
|
83464293 |
HavardGris |
B |
June 11, 2020, 4:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
0 |
|
|
83446069 |
Flander |
B |
June 11, 2020, 4:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
0 |
|
|
83490141 |
1912607519 |
B |
June 12, 2020, 1:59 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
31 |
0 |
|
|
83543122 |
a1ikeda |
B |
June 12, 2020, 3:08 p.m. |
OK |
Perl |
TESTS |
4 |
15 |
0 |
|
|
83454545 |
amit_dwivedi |
B |
June 11, 2020, 4:25 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
124 |
716800 |
|
|
83501554 |
alexwice |
B |
June 12, 2020, 5:55 a.m. |
OK |
PyPy 2 |
TESTS |
4 |
139 |
1945600 |
|
|
83453500 |
bazzyadb |
B |
June 11, 2020, 4:23 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
155 |
716800 |
|
|
83484986 |
lebron87 |
B |
June 11, 2020, 10:30 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
171 |
1843200 |
|
|
83447214 |
beethoven97 |
B |
June 11, 2020, 4:10 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
202 |
3584000 |
|
|
83461877 |
mo-hit |
B |
June 11, 2020, 4:40 p.m. |
OK |
PyPy 2 |
TESTS |
4 |
218 |
9420800 |
|
|
83512613 |
snape_here |
B |
June 12, 2020, 8:36 a.m. |
OK |
PyPy 2 |
TESTS |
4 |
234 |
7577600 |
|
|
83470600 |
sanjeevkumar113f |
B |
June 11, 2020, 5:51 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
139 |
1843200 |
|
|
83507405 |
thekushalghosh |
B |
June 12, 2020, 7:23 a.m. |
OK |
PyPy 3 |
TESTS |
4 |
139 |
2150400 |
|
|
83448524 |
SpicyKong |
B |
June 11, 2020, 4:13 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
139 |
2252800 |
|
|
83513820 |
arpit_pandeyy |
B |
June 12, 2020, 8:54 a.m. |
OK |
PyPy 3 |
TESTS |
4 |
139 |
2355200 |
|
|
83443287 |
cdryme |
B |
June 11, 2020, 4:02 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
1843200 |
|
|
83449289 |
Scopula |
B |
June 11, 2020, 4:15 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
1945600 |
|
|
83537782 |
thekushalghosh |
B |
June 12, 2020, 2:07 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2150400 |
|
|
83495144 |
2019ucp1350 |
B |
June 12, 2020, 4 a.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2252800 |
|
|
83465408 |
Sameer-Mann |
B |
June 11, 2020, 5 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2355200 |
|
|
83496533 |
akifpathan |
B |
June 12, 2020, 4:32 a.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
66867200 |
|
|
83485561 |
ComptineDunAutreEte |
B |
June 11, 2020, 10:52 p.m. |
OK |
Python 2 |
TESTS |
4 |
170 |
0 |
|
|
83508658 |
sainad |
B |
June 12, 2020, 7:40 a.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83507810 |
incognito__ |
B |
June 12, 2020, 7:29 a.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83500958 |
aviation_0699 |
B |
June 12, 2020, 5:46 a.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83500943 |
eugalt |
B |
June 12, 2020, 5:46 a.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83484503 |
abdul_ghani_07 |
B |
June 11, 2020, 10:13 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83476471 |
LintuStorm |
B |
June 11, 2020, 7:06 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83468976 |
rougef4ak |
B |
June 11, 2020, 5:33 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83468212 |
maraj262000 |
B |
June 11, 2020, 5:25 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83467627 |
coder199 |
B |
June 11, 2020, 5:20 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83463932 |
Rabi02 |
B |
June 11, 2020, 4:50 p.m. |
OK |
Python 3 |
TESTS |
4 |
93 |
0 |
|
|
83443523 |
bqn |
B |
June 11, 2020, 4:03 p.m. |
OK |
Rust |
TESTS |
4 |
31 |
0 |
|
|
remove filters
Back to search problems