DCP-300: Shan and String Back to All Problems

Hard Data Structures > Segment Tree/Interval Tree


There is a little boy name Shan. One day he came up with a problem. Now you have to solve that problem. You will be given a Binary string S which contain either 0 or 1. Now you have to do two types of task. 1 x :- Change the value at x'th position. If the value is 1 then change it to 0 Or, if the value is 0 then change it to 1. (Toggle operation) 2 x y :- Find number of 1's block between two indexes x and y (inclusive). **A block of 1's is a maximal consecutive substring that only contains 1.** Input: ------- The first line of input contains integers N and M. N is the length of the string and M is the number of tasks to do. The Next line contains a string S. The Next M line contains a task either task 1 or 2. **( 1<=N<=100000 , 1<=M<=100000, 1<=x<=y<=N )** Output: ------- For each second type of task you have to output one integer representing it's result. Sample Input ------------ 10 5 1101011101 2 1 10 2 7 10 1 8 2 7 10 2 2 8 Sample Output ------------- 4 2 2 3


Problem Setter:

S.M. SHAHEEN SHA

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 2.00
C++ 2.00
C++14 2.00
C# 3.00
Go 3.00
Java 3.00
JavaScript 3.00
Objective-C 3.00
Perl 3.00
PHP 3.00
Python 3.00
Python3 3.00
Ruby 3.00
VB.Net 3.00

Problem Stats

41/88

Solve/Submission

Ranking

# User Language Timing
01 Morass Cpp14 0.02s
02 njrafi Cpp14 0.03s
03 feodorv Cpp14 0.03s
04 GustavoCandido Cpp14 0.04s
05 ksohan Cpp14 0.04s
06 jahid_ict Cpp14 0.04s
07 last_man Cpp14 0.04s
08 ____ Cpp14 0.05s
09 fsshakkhor Cpp14 0.05s
10 Nirjhor Cpp14 0.05s
11 khatribiru Cpp14 0.05s
12 sayedgkm Cpp14 0.06s
13 mamun4122 Cpp14 0.06s
14 rubabredwan Cpp14 0.06s
15 sahedsohel Cpp14 0.06s
16 ehsan_sshuvo96 Cpp 0.06s
17 tariqiitju Cpp 0.06s
18 Sarwar05 Cpp14 0.06s
19 Protap_Ghose Cpp14 0.06s
20 Jisancse Cpp 0.06s
21 Rajib_119 Cpp14 0.07s
22 adamantium Cpp14 0.07s
23 imAnik Cpp14 0.07s
24 lightlessShadO Cpp14 0.07s
25 Double_O Cpp14 0.08s
26 as_couple Cpp14 0.09s
27 acraider Cpp14 0.10s
28 skmonir Cpp14 0.11s
29 seyedssz Cpp14 0.12s
30 nasib_mbstu Cpp 0.13s
31 Digonta Cpp 0.15s
32 I_See_You Cpp14 0.20s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support