I was trying to solve subsequences http://mirror.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.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Proof_by_QED | 146 |
| 3 | Um_nik | 146 |
| 5 | Dominater069 | 144 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
I was trying to solve subsequences http://mirror.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.
| Name |
|---|



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://mirror.codeforces.com/contest/597/submission/14321058 :)
Apologies in advance if revisiting old post is a taboo on code forces.
But I can't help wonder why did my solution resulted in a TLE
http://mirror.codeforces.com/contest/597/submission/18835377
Shouldn't this have the same time complexity with the one just mentioned?
You missed the tree.
Thanks a lot, just googled BIT online. My mind is completely blown now, now I see why some of the code contains weird x&(-x) equations.
bad
yeeeeee
One dumbass little child at our ioi team trainings posted these when my computer was free to get my contribution down. Temotoloraia so just please don't minus.
I made mistake, I'm sorry