hanoi11minh_nh's blog

By hanoi11minh_nh, history, 10 days ago, In English

Hello Codeforces,

I am encountering a problem that I am unable to solve:

I need to print the order from fold l to r of folding up and down a piece of paper after ( n ) times of performing two folds alternately left and right. Please use 'D' for Down and 'U' for Up. Input: n, l and r. For example: Input: 2 1 3 Output: DDU

Note that folding left means folding the right edge over the left edge, and folding right means folding the left edge over the right edge.

I have a rough idea of using a deque to store the order, but I can't figure out the exact algorithm for this problem.

Can you provide some hints?

Thank you!

Edit: Also 1<=n<=60, 1<=l<r<=2^n and r-l<=10^6

Full text and comments »

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

By hanoi11minh_nh, history, 11 days ago, In English

Hello Codeforces!

I am facing this problem and don't know how to avoid TLE. Can someone please give me an algorithm hint for this problem? I already know the O(n^2) way.

Here is the problem:

We have n numbers which are the lengths of the sticks. Find the number of unique triangles that can be formed from the given n sticks. Unique triangles are understood as triangles that do not have a pair of 3 identical sides. Note that n<=5000 and each stick's length is <= 1e9

Thank you.

Note: I can solve it know, thanks.

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it