| # | User | Rating |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | maspy | 150 |
| 3 | Um_nik | 145 |
| 4 | Errichto | 139 |
| 5 | nik_exists | 138 |
| 6 | adamant | 136 |
| 7 | maroonrk | 134 |
| 8 | DNR | 132 |
| 9 | AmShZ | 131 |
| 10 | Dominater069 | 129 |
|
0
Auto comment: topic has been updated by viralm (previous revision, new revision, compare). |
|
0
Auto comment: topic has been updated by viralm (previous revision, new revision, compare). |
|
-11
Thanks mgcd. |
|
0
It is probably because this website is for mobile phones. I think you should scroll down and click on switch to Desktop Version. :) |
|
On
Ripatti →
A little bit of classics: dynamic programming over subsets and paths in graphs, 10 years ago
-8
In the 7th section, how are those paths included in the answer where we use vertices v < first(mask). This means, if our bit representation of mask is 1101000, and we want to count no. of paths starting at first(mask)=3(3rd bit, 0-based indexing from right to left) and ending at vertex v=5(0-based indexing from right to left), how will paths like the one starting from vertex 3 to vertex 5 with vertex 0 on the way(and similar) be counted if we use the dp meaning given in section 7? |
|
0
Can you explain your code? |
|
0
Sorry. You are right. |
|
0
Your code gets into an infinite loop when lo==hi. |
|
0
Here is my approach to solving D. 1.Let's first store a vector {l,r} in another vector for all queries. Let's denote this vector of vectors as v. 2.Now sort this vector.Now we have a vector containing l,r pairs sorted by l. 3.Now here is the analysis — The answer to our question is a range such that its 2 endpoints belong to the set of points obtained from queries. Whenever we get a query of form l,r, we include l and r in this set of points. Lets call this set pts. So our 2 end points belong to pts. 4. Now we plan to iterate over the pts set(stored in a vector). We also make a set<vector> called st. Now as we iterate over pts, we keep in our set only those ranges from v such that their l <= pts[i]. We put the sanges into st in the form {r,l}, so that the ranges in set are sorted by r. 5. We plan to use 2 pointer technique here. For each i over pts we increase j (which is also iterator over pts) and remove all ranges from st whose r<pts[j] till the size of st > k. 6.The answer is max of all pts[j] -pts[i]. 7. There are definately a lot of details left to be explained but are not very difficult to figure out. This is just the basic idea. 8. If you feel something wrong with this approach, feel free to tell me. |
|
0
In order to use kmp, we need to keep track of the LCS found upto a particular state. How do you suggest to do that? Should I store the LCS itself in another array[][][] ? |
|
0
Anyone? |
|
0
Auto comment: topic has been updated by viralm (previous revision, new revision, compare). |
|
0
I think you can take the negative of all edge weights and apply the Bellman–Ford Algorithm. Your final answer will be the negative of the answer given by Bellman–Ford Algorithm. This works because, Bellman–Ford Algorithm is used to calculate the shortest path from source node to every other node. Now, if you negate all edge weights, then the abs(length of shortest path) = length of longest path. You can read more about Bellman–Ford Algorithm here — http://www.geeksforgeeks.org/dynamic-programming-set-23-bellman-ford-algorithm/ |
|
+3
I know. Just wanted to give an alternative approach. :P |
|
0
In above solution, I have assumed that 2 or more subsequences having the same sum are counted more than once. |
|
0
|
|
0
My code for Problem C, small — http://ideone.com/bxHN0y |
|
0
I think you need to use dynamic programming, for problem C. |
|
0
Can be done in logn time using Fenwick tree or BIT. I assume that some preprocessing is allowed. As far as I know, femwick tree is not part of STL. |
|
0
I think it is not possible in this way because it might be the case that as you move from the root towards the leaves, allowing the root node to have a mismatch might lead to the best possible answer. |
|
0
Auto comment: topic has been updated by viralm (previous revision, new revision, compare). |
|
+1
OK |
| Name |
|---|


