1 / 10

3.12 ≠ π

3.12 ≠ π. What an inspiring title. PotW Solution - Bovinekiin.

pippa
Télécharger la présentation

3.12 ≠ π

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3.12 ≠ π What an inspiring title

  2. PotW Solution - Bovinekiin int stall = 0;for (inti = 0; i < 90001; i++) {inta = rand.nextInt(n);intb = rand.nextInt(n); Item temp = cur.get(a);cur.set(a, cur.get(b));cur.set(b, temp);if(calcGreedy(cur) > calcGreedy(best)) { best = newArrayList<Item>(cur); // update best } else { cur = newArrayList<Item>(best); // restore best stall++;if(stall == 9001) Collections.shuffle(cur); }}printSolution(best); • Full solution at http://ideone.com/yHPi6

  3. About Harker • Deadline to register was last Saturday • You probably received an email with info if you’re registered • Read it! • Schedule • 8:30-9:30 Check-in • 9:30-10:30 Speaker • 10:30-10:40 Break • 10:40-11:00 Diagnostics/Introduction to competition infrastructure • 11:00-12:30 Competition • 12:30-1:45 Lunch • 1:45-2:00 Set-up for Challenge Round • 2:00-2:30 Challenge Round • 2:30-3:00 Awards and Raffle

  4. March USACO I know this title is off-center, but that’s the way this slide theme works.

  5. Bronze – Times 17 • Given a number N, print 17 * N. • The catch: Input and output are in binary, and N may have up to 1000 digits • The solution: 17N = 16N + N • 16N in binary is just N followed by four 0s • Simple binary addition to add 16N to N

  6. Silver – Flowerpot • Given the locations of N raindrops in the 2D plane, compute the minimum width of a flowerpot along the x-axis such that the vertical distance between the first and last raindrop to hit the flowerpot is at least some value D. • 1 <= N <= 100000 • 1 <= D <= 1000000

  7. Flowerpot – Solution • Sort all points by x-value, “sweep” a pair of vertical lines from left to right • Store y-values of points between sweep lines in a data structure that can easily find min and max • Such as pair of priority queues • Whenever difference btwn. min and max is at least D, check if this is best (min.) flowerpot width so far and advance left sweep line • If not at least D, advance right sweep line

  8. Gold – Skyscraper • Given an elevator with a weight capacity, what is the minimal number of trips that will be needed to deliver n < 18 cows with certain weights from one floor of a skyscraper to the next. n < 18, so the solution is probably exponential in time • Use dynamic programming • The state is a bitmask of n bits: O(2n) • ith bit on: ith cow delivered, off: ith cow not delivered • The DP function maps the bitmask to a pair of integers: • First, what's the minimum # of occupied elevators that must be used to carry these cows • Second, what's the minimum amount of weight in the last elevator given this minimal # of elevators

  9. Skyscraper – Dynamic Programming • This DP function only takes into account the weight of last elevator (weights in the other elevators are ignored) • Minimize # of occupied elevators first • Then minimize amount of weight in last elevator • Basically just find the minimal pair lexicographically • Base Case: • DP(all 0s) = (0, 0) • Recurrence: • Try adding each non-used cow (of weight W) to the last elevator (adds insignificant factor of O(n)) • If it overflows the capacity, add a new elevator, and let the last elevator have weight W • If it doesn't, add W to the last elevator

  10. No PotW this week! • Have fun at Harkerthis Saturday!

More Related