Блог пользователя javacoder1

Автор javacoder1, история, 8 лет назад, По-английски

I was trying to solve subsequences http://codeforces.com/problemset/problem/597/C of Testing Round #12 but could not figure out the solution.Can anyone explain the solution using binary indexed tree.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

We will loop from 1 to N and at each step dp[i][j] will be the number of increasing subsequences of length i ending at element with value j. Let's say that the current element is a[i]. Obviously, this is a new subsequence of length 1 ending at a[i]. So we will do ++dp[1][a[i]]. Then for j from 2 to K we will do dp[j][a[i]]+=(dp[j-1][1]+dp[j-1][2]+dp[j][3]+...+dp[j-1][a[i]-1]) since we can extend every subsequence of length j-1 which ends in an element which is less that the current one :)

Here is my submission — http://codeforces.com/contest/597/submission/14321058 :)

»
8 лет назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

bad

»
8 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

yeeeeee