Debugging is a great skill. You won't achieve that if you just tell others to debug your code.

Active In

Competitive Programming

International Olympiad in Informatics

Indian Computing Olympiad (ICO)

International Mathematics Olympiad

Featured Contributions

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

Debugging is a great skill. You won't achieve that if you just tell others to debug your code.

Read more… (18 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

Consider a polynomial

**P(x) = x^a0 + x^a1 + x^a2 + x^a3 + ..... + x^an **

Now count of **(i, j, k, l)** such that **a[i] + a[j] + a[k] + a[l] = T** is just coefficient of **x^T** in** P(x)^4**

But you need to adjust the answer because this method counts all permutations of (i, j, k, l) as different!

Read more… (61 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

For a Hard version, solve the problem when N <= 10^5, and S[i] < 2^16.

Read more… (15 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

I know this is OVERKILL. But maybe the most simply understandable solution -

Read more… (92 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

Why O(n^3) should pass? -_-

n <= 700, O(n^3) should take approximately 3.5 seconds :|

Read more… (15 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

I think the post is not well-phased. If you keep some array in each node of Segment Tree, that doesn't make a segment tree a 2D segment tree. 2D segment trees are different.

However, I've seen so many people who think quad-tree is 2D segment tree. Where each node has 4 child.

But most of them don't know quad-tree is O(n) per query in worst case or even worse, while 2D segment tree can query in sub-grid in O(log^2 n). That because maybe googling with 2D segment tree, a stackoverflow post comes up that describes quad-tree as 2D segment tree :3

Read more… (101 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

Read more… (6 words)

Contributed 100%

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

I also wonder why no blog / algorithm books promote this algo :P This is still pretty much unknown algorithm :P

Read more… (21 words)

comment in this discussion

Rezwan ArefinLove Competitive Programming and Mathematics · 3y

I think for ConvexHull "Monotonic Chain Method" is more simple than "Graham Scan". It is also very easy to understand why and how it works.

In this method, we first find the left most point, start from that and go to right as long as we can, in CCW order. They will form a lower hull

Then from the rightmost point, we again go in CCW order as long as we can, they will form the upper hull.

Here is a full explanation - Convex hull-Monotone chain

Read more… (87 words)