presumption's blog

By presumption, history, 10 months ago, In English

I was recently up-solving AtCoder Beginner Contest 339 and came across a Persistent Segment Tree Problem G — Smaller Sum.

While implementing my own Persistent Segment Tree. I tried to make it as generic as possible.

Code:

Here are few things that I want your help and opinion on:

  • Is their a more generic and efficient way to implement Persistent Segment Tree? and How to improve the above code?
  • How can you identify if a problem uses Persistent Segment Tree?
  • Is their a better way to implement custom allocator for Competitive Programming(or for C++/C projects)?
  • How to implement Lazy Persistent Segment Tree?
  • How to add documentation to Personal Library codes?

Upd: I re-wrote the Persistent Segment Tree with documentation and without custom allocator. Thanks to lrvideckis and NimaAryan for help.

Code:

Full text and comments »

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

By presumption, history, 21 month(s) ago, In English

Here are few questions that I had about maintaining a code/snippet library:

  • How do you usually test your code for the library? Any submission link for standard data structures or algorithms?
  • What are some things to keep in mind while writing a code/snippet library? (Suggestion about documentation, unit tests, etc)
  • Can you share your library and what you like or not-like about your library? How would you like to improve it?
  • What are some well-written libraries that someone can use as Black Box?
  • How do people using vim maintain their snippets? (Specifically neovim with lua)

Can someone share the library used by jiangly?

Full text and comments »

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

By presumption, history, 21 month(s) ago, In English

Given a tree with $$$n$$$ vertices.
You are also given $$$q$$$ queries and each query is described by $$$2$$$ vertices of the tree.

You have to count the number of times each vertex was visited after processing all the queries.
Processing a query means you travel form one vertex in that query to other vertex and you visit all the vertices including the starting vertex, ending vertex, and all the other vertices in the path once.

My Questions about the Problem:

  • Is it possible to solve the above problem if $$$1 ≤ n ≤ 10^5$$$ and $$$1 ≤ q ≤ 10^5$$$?
  • What are the steps or algorithm for solving this problem?
  • Is their any data structure or algorithm which can be used if after some queries we are asked how many time a particular vertex has been visited?

Full text and comments »

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

By presumption, history, 23 months ago, In English

I have seen many 2 Player Game problems while solving problems on codeforces, and these problems don't follow a specific methodology for solving them. Is there any method or way to go about thinking/modeling these problems in general?

Full text and comments »

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