| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3447 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | turmax | 3317 |
| 9 | tourist | 3307 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 141 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 7 | AmShZ | 135 |
| 8 | BledDest | 132 |
| 9 | maroonrk | 131 |
| 10 | qwexd | 129 |
|
+16
4pm UTC (11am EST) on Tuesday, if I calculated correctly. |
|
+30
Thanks for pointing this out; the issue was that the sample case was not the first test case. This is being fixed and past submissions are being regraded. |
|
+10
Subtracting k from |
|
+19
Thanks for pointing it out! My solution should now be fixed. |
|
0
I believe the solution is correct as is, though the number of parentheses is admittedly confusing. We are subtracting s[N] - s[N - 1] from the total number of ways. |
|
On
vamaddur →
Is my alternate approach to USACO 2012 Gold December Contest: "Running Away From the Barn" valid?, 9 years ago
+3
Take a look at the C/C++ technical details on the instructions page (http://www.usaco.org/index.php?page=instructions). |
|
+119
Maybe the judge decided to perform some rounding... |
|
On
vamaddur →
How can I solve USACO 2011 Gold December Grass Planting Without Heavy-Light Decomposition (HLD)?, 9 years ago
+13
Minor typo — I think you mean "decrement L twice." |
|
0
These are the steps I used to compare two pairs (of a base point + a vector):
To check which point is "further along" we can just check if the dot product of their difference with the line vector is positive or negative. |
|
+20
This exact solution worked for me. The only optimizations I made were using no floating point operations (which might have been necessary anyway to deal with parallel lines and collinearity), and looping through only N(N - 1) / 2 lines rather than N(N - 1) lines (though that this works might have been obvious to other people, at first it wasn't to me). Also, it's not necessary to figure out the list of points on a line and reverse them. If we sort the lines (i.e. pairs of points) properly, at each time-step we can just swap the two points which define the current line. After all pairs of points with a certain slope are processed, the points on one line will be reversed. |
|
+23
|
|
0
Does anyone know if accounts from main.edu.pl will be migrated to szkopul.edu.pl too? |
|
+5
My guess (which could be completely wrong) was that there is no faster solution aside from improvements in matrix multiplication. This problem seems to be equivalent, in some sense, to multiplying and exponentiating matrices. |
|
+1
Since we have to remove the case when r=1, we must subtract 1 from the final answer (so for n=5, we get 3). The answer for n=5 should be 3, since we also have the sum of 15 consecutive positive integers (120 = 1 + 2 + ... + 14 + 15). |
|
0
Sure. To get that first formula, notice that ![]() Simplifying the formula in my previous comment, we get Instead of counting all pairs (r,a) we will count all pairs (r,r+2a+1) because it's simpler: now we're just counting all ordered pairs (x,y) with xy = 2N! where x<y and x and y have different parity. This is equivalent to counting the number of odd divisors of 2N!. I can explain the solution to this reduced problem if you're still stuck. |
|
+5
Any sum of consecutive integers can be described by a low value a and a length r. So we must have: ![]() Try simplifying this expression and then factoring it. |
|
+3
Here we go: 14144018 |
|
+18
Here's my solution, which receives full points after a small bug-fix: We binary search on D, so now we need to solve the problem of finding whether a given value of D works. This is in two parts: joining with union-find all points within distance D, and then applying knapsack to each component to test if some subset adds to 0 mod K. Part 1: Scan by x-value, maintaining a set sorted by y-value of all points with x-value at most D behind the leading line. Now for each point (a,b) in our scan, we iterate in the set through all points in this set with y-value in (b-D,b+D), and join to (a,b) all points within distance D. These are the points in the rectangle [a-d,a]x[b-D,b+D]. Note that by Pigeonhole, if we ever find a component of size at least K, we may stop and return a YES. This short-circuiting means (I think) that there can only be ~180 points in this box without more than K points lying in close proximity, and in most cases there should be much less. Part 2 modulo knapsack is quite easy, so of course this is where I made a bug. This solution is O(N*K*log(MAX_DIST)) but runs in less than 0.5 seconds on the test data. |
|
+3
Here's my understanding of the solution provided in your link: A sufficiently 'nice' sum that depends only on N will be a polynomial on N. I don't have a definition of 'nice' or a proof that this sum is 'nice', but several examples should convince you of this — Furthermore, the degree of the polynomial should be 10. We're multiplying five terms and summing over five variables. Again, take a look at the above examples — the third one should be a degree-three polynomial in N, as we are multiplying one term and summing over two variables. Unfortunately, we don't know the coefficients of this magical 10th degree polynomial. However, we can find them if we have 10 linear equations in terms of these coefficients. Let P(N) = c10x10 + ... + c1x + c0. Then our desired equations are P(Ni) = c10(Ni)10 + ... + c1Ni + c0 for 10 different Ni, where P(Ni) must be calculated manually or with a slow program. Finally, we put these equations into an augmented matrix and use Gaussian elimination to solve for the 'variables', which are the 10 coefficients ci. Now we simply evaluate P(N) for each given N. |
|
+77
Well, he gave 167 people a contest to remember. Thank you tourist! |
|
+9
The line " if ( L — lo > 1 || ans != -1) " doesn't take into account the case where L > hi. Try this case, for example: 4 2 Here's your code modified to pass: 12140485 |
|
0
Thanks, fixed. |
|
+14
Here's another O(N log(N)) solution for C (which can be made O(N) with a simple modification). Let ans[i] be the number of moves to reach the state where all numbers are equal to i. Also, notice that any minimal sequence of moves for one number consists of some number of divisions, followed by some number of multiplications. Now suppose that we have ans[k / 2] and want to find ans[k]. Case 1: k is even. Every number i that cannot reach k with only divisions must end its sequence of moves i - > ... - > k with a multiplication k / 2 - > 2 * (k / 2) = k, so it requires one more move to reach k than to reach k/2. Every number i that can reach k with only divisions must pass through k on any minimal sequence i - > ... - > k / 2, so it requires one less move to reach k than to reach k/2. Case 2: k is odd. By the above logic, the final number can only be k if every i can reach k with only divisions: a multiplication by 2 can never end up at k. If this condition is satisfied, we proceed as above; if not, we mark k as impossible to reach. Thus if we pre-compute in O(N) the array nreach[i] = number of numbers which can reach i with only divisions, and pre-compute in O(N log(N)) or O(N) ans[1], we can calculate ans[k] for all values of k in O(N) with the formula ans[k] = ans[k / 2] + (N - nreach[k]) - nreach[k]. |
| Name |
|---|


