sayan_244's blog

By sayan_244, history, 6 months ago, In English

Hello everyone. I was trying to learn how GDB works and learn about debugging.

While trying to set breakpoint on main function I saw that it's not displaying the line number in decimal.

So I looked up a bit and found that one needs to include the -g flag while compiling the cpp file.

I did that and yet it doesn't show the line numbers in decimal. (Thereafter I tried to search this up but couldn't get the issue resolved)

My GDB version is 7.6.1 (probably latest for windows)

https://www.imageupload.net/image/gdb-issue.KQ1E2

If someone can help me out with this it would be much appreciated.

UPD: Found out issue. Seems like compilation generates a separate file (a.out) and you have to run gdb on that file.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By sayan_244, history, 9 months ago, In English

Hello guys.

I was trying the problem https://codeforces.com/contest/182/problem/D

The intended complexity of my solution is supposed to be $$$O(n\sqrt{n})$$$ but somehow I was repeatedly getting TLE. When I switched the concerned part where I was using + for concatenation of two strings with append it got accepted.

I went over to stackoverflow for figuring out the cause but I couldn't understand much of it besides trying the reserve keyword. I also tried using the reserve keyword for reserving space for the string but it resulted in TLE as well.

Here are my submissions:-

https://codeforces.com/contest/182/submission/82678284 -Using append.

https://codeforces.com/contest/182/submission/82677975 -Using + for concatenation.

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

By sayan_244, history, 10 months ago, In English

While learning about segment tree I came across this problem:-

The task is as follows: for a given value x we have to quickly find smallest index i such that the sum of the first i elements of the array a[] is greater or equal to x (assuming that the array a[] only contains non-negative values).

Link-https://cp-algorithms.com/data_structures/segment_tree.html

The solution mentions storing prefix sums in the segment trees.

I cannot figure out how to build up a segment tree of prefix sums. Also how is it different from the range sums?

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it