nhphuc's blog

By nhphuc, history, 3 days ago, In English

Today, I tried to solve a problem like this:

  • Given $$$n$$$ convex hull, convex hull $$$i$$$ have size $$$m_i$$$, begin, you started in convex hull number $$$1$$$, then, with a operation, you can do:
  1. Teleport to any points in current convex hull (with cost $$$0$$$), then use a balloon to fly to a point in another convex hull with cost is Euclid's distance between that two points.

  2. Teleport to any points in any convex hull that you have visited with cost $$$0$$$.

Find minium cost to visit all the convex hull.

Input: $$$1\leq n, m_i\leq 200$$$.

My main idea to this problem is, find all edge between two convex hulls (easy to see, cost of that edge is closest distance between that two convex hulls, let call is $$$X$$$), then build the MST, answer is sum of the all cost of edge in MST.

But, I just can find the $$$X$$$ of two convex hulls in $$$O(m^2)$$$ and can't do better, can anyone help me with this. Thank you and sorry for my bad English.

Full text and comments »

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

By nhphuc, history, 3 weeks ago, In English

Today I was try to solve this problem: https://codeforces.net/gym/100952/problem/J.

My main idea is:

  • Find all point $$$X$$$s that $$$X$$$ is a node of $$$A$$$ and in $$$B$$$'s area.

  • Find all point $$$X$$$s that $$$X$$$ is a node of $$$B$$$ and in $$$A$$$'s area.

  • Find all intersection points of $$$A$$$ and $$$B$$$.

Let call the set of points we found is $$$S$$$, $$$S$$$ will be a convex hull, find the area of $$$S$$$ — the answer of problem.

But somehow I get WA verdict, can anyone help me to find out why, thanks all.

(This is my code: https://ideone.com/8wXu6a)

I have AC but now I have a weird problem: with the same code, sometime it AC but sometime it WA, is this a issue of Codeforces's judge or just my skill issue ;-;.

Full text and comments »

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

By nhphuc, history, 4 months ago, In English

I see that dijkstra (and some shortest path algorithm) have a lot of variants like the roads have color, money and time to pass on a road,... etc. So, how to I practice them and how should I thinking for these problem.

Anyone please help me, I'm very need a help now, my national team selection contest is coming.

Full text and comments »

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

By nhphuc, 13 months ago, In English

I'm currently learning fenwick tree and I find it quite difficult (in my opinion, it's more difficult than segment tree). As far as I know, most problems that can be solved with a fenwick tree can also be solved with a segment tree. So, in addition to memory optimization and simple usage, is there anything more optimal about fenwick tree than segment tree? And, sure, can anyone give me websites to use to learn fenwick tree? Thank you.

Full text and comments »

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