| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | jiangly | 3670 |
| 3 | Kevin114514 | 3657 |
| 4 | maroonrk | 3355 |
| 5 | Um_nik | 3353 |
| 6 | squareOf105 | 3346 |
| 7 | tourist | 3343 |
| 8 | strapple | 3324 |
| 9 | heuristica | 3322 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | AmShZ | 143 |
| 5 | Um_nik | 141 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 133 |
| 8 | maroonrk | 133 |
| 10 | qwexd | 130 |
|
0
Your code seems to also check the next element when trying to add the current element in. Try this case: n = 3, w = 10 items = [2, 2, 9] |
|
+31
damn. For problem D, I thought the first condition was "if you can determine that number, print 1" for some reason. rip. How did I get 10 pretest cases? |
|
0
jk plz ignore, not a runtime error, but memory limit exceeded :| (solved) |
|
0
can someone help me debug for plat #3 plz. getting some weird runtime errors for the last few test cases (got cucked by regrading) code |
|
+2
You made a pretty simple mistake. When you insert into your stack, you check to see whether it was visited right? However, as you insert it into your stack, you do not change the status of the vertex into "visited." This allows the same vertex to be inserted into the stack multiple times, causing your time complexity to boom. I was too lazy to read the problem, so I just skimmed through your code and found that small error. Your code after the change |
|
0
There can be multiple stars at a point. Also, it seems that you are looping through the rectangle of each view, which might be too many operations to fit in the time limit. |
|
+3
I think he means div 1. E |
|
+1
Keep an array of indices, (we have an array a of length 2,000,000, if a[i] is marked with an index j, this means that there is an occurrence of string j at position i, if multiple strings occur at the same position, save the index of the longest string which occurs at that position). Then, we loop through all of the positions. For each position, if the position is marked and we are not currently printing a string, then we start printing the string marked by the current position. If a position is marked and we are currently printing a string, then we check to see whether the leftover string we are currently printing is longer than the string marked on the current position. If the string marked on the current position is longer than the leftover string we are currently printing, then we stop printing the leftover string and start printing the string marked on the current position. If a position is not marked and we are not in the middle of printing a string, then we just print 'a', since 'a' is the smallest letter. |
|
+4
I need to bookmark this :P |
|
On
vamaddur →
Is my alternate approach to USACO 2012 Gold December Contest: "Running Away From the Barn" valid?, 9 years ago
0
It seems like it's just some issues with IO methods. First, you should change scanf("%d %d", &N, &L) to scanf("%d %lld", &N, &L), seems like you forgot that L was long long. Also, you should try to use the %lld flag isntead of %I64 for USACO, or at least that's what the specifications page says, not sure whether it actually changes anything. I tried submitting your solution after altering the items above. It works. |
|
0
Would this approach work? First, reverse the string S and call it string B. Calculate all values for dp[prefix of S][prefix of B] = longest common subsequence of [prefix of S] and [prefix of B]. You can calculate this in O(N^2). Then, you loop through all prefixes of S and prefixes of B where S and B do not intersect and find the maximum length. If there are multiple states that have the maximal answer, then choose the state where the length of the prefix of S is minimal. |
|
0
If you run bellman-ford's algorithm on these states to find the shortest path, it shouldn't really matter? |
|
0
I think you can alter the bitmasking so that it can visit one city more than one time. First, you can maintain an array dp[bitmasks of cities visited][current city]. Normally for bitmasks, you only try to transition to different bitmasks (i.e. you wouldn't transition from [110110][2] to [110110][3]), but in your case, you can alter the transitions a bit and allow such transitions to occur. |
|
On
vamaddur →
How can I solve USACO 2011 Gold December Grass Planting Without Heavy-Light Decomposition (HLD)?, 9 years ago
0
Oh I see! Thank you for pointing this out to me! Learn something new every day :D Thank you for helping out! |
|
On
vamaddur →
How can I solve USACO 2011 Gold December Grass Planting Without Heavy-Light Decomposition (HLD)?, 9 years ago
0
But how exactly should you increment the edges on the path by using the dfs preorder? The main solution does it by using Heavy-Light but I am not sure how to do the same thing with DFS and Segment Tree/BIT? |
|
On
vamaddur →
How can I solve USACO 2011 Gold December Grass Planting Without Heavy-Light Decomposition (HLD)?, 9 years ago
0
O.O (red coder!!) Sorry, I don't really understand some parts of your solution. What is path root? How do we process the addition and queries by using BIT? Could I ask for some more details about your solution? Thanks :D |
|
On
vamaddur →
How can I solve USACO 2011 Gold December Grass Planting Without Heavy-Light Decomposition (HLD)?, 9 years ago
0
I don't think it is very plausible to solve Grass Planting with a Segment Tree representing the nodes of the tree. In order to a segment tree to actually be useful, you usually want to update a small number of contiguous segments, or else the time complexity will be huge. For the problem in the January contest, the preorder traversal was done to be able to update all the children of a node at once (in one contiguous segment). However in this problem, you need to update paths from one node from another, and I believe it is impossible(at least according to my current knowledge) to maintain an ordering so that you can update all the nodes on the path at once or at least efficiently. Why not Heavy-Light Decomposition? Researching it would be useful in the future. P.S. Though I think it is unlikely that another solution exists, I would also be very interested if there is a solution other than using Heavy-Light Decomposition. |
|
0
I have a question for Problem F: since k * (k-1) / 2 is increasing and n-k is decreasing, wouldn't the maximal value of the function be at the index where k * (k-1) / 2 becomes greater than n-k? If that is true, could we just binary search to find the point where k * (k-1) / 2 > n-k, and get our answer from there? Submission: 28155258 (Sorry not so familiar with ternary search so just asking) |
| Name |
|---|


