1 / 11

Gunn ProCo

Gunn ProCo. Lynbrook 1st, 2nd, 3rd*, 4th. Results!. 1st: Johnny, MG, Victor (perfect score) 2nd: Julia, Tony, Jimmy (perfect score) 3rd: Team "Lynbrook High School" (Eugene Chen, Douglas Chen, Andrew He) 4th: Joshua, Dolly, Steven. Lessons learned. Making bugs wastes tons of time

mirari
Télécharger la présentation

Gunn ProCo

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. Gunn ProCo Lynbrook 1st, 2nd, 3rd*, 4th

  2. Results! • 1st: Johnny, MG, Victor (perfect score) • 2nd: Julia, Tony, Jimmy (perfect score) • 3rd: Team "Lynbrook High School" (Eugene Chen, Douglas Chen, Andrew He) • 4th: Joshua, Dolly, Steven

  3. Lessons learned • Making bugs wastes tons of time • Pay attention to small details • The problem statements might have errors • Life is tough. Deal with it. • No penalty for wrong submissions: just keep trying • C++ I/O is annoying • Be on Johnny's team

  4. Cow Placement • N seats • K antisocial cows • Each cow picks the largest empty segment to sit in and sits in the middle of the segment • Break ties by choosing the leftmost segment/seat • E.g. N = 4 and K = 3 • _ _ _ _ • _ o _ _ • _ o o _ • o o o _ • Output is "o o o _"

  5. Cow Placement: Solution • Need O(nlogn) time • Scanning through the empty segments and selecting the largest one every time is too slow • O(n^2) • Instead, use a priority queue that stores empty segments • Start by pushing (1, N) into the queue • Use a custom comparator to sort by decreasing length, then increasing index

  6. Custom Comparator (Java) public class Seg implements Comparable<Seg> { int a, b; public int len() { return b - a + 1; } public int compareTo(Seg& oth) { if (len() != oth.len()) return len() > oth.len() ? -1 : 1; if (a != oth.a) return a < oth.a ? -1 : 1; return 0; }

  7. Custom Comparator (C++) typedef pair<int, int> pii; int len(pii a) { return a.second - a.first + 1; } struct comp { //priority_queue is a max-heap. bool operator()(pii& a, pii& b) { if (len(a) != len(b)) return len(a) > len(b); return a.first < b.first; } };

  8. Disk Placement • 5 disks of diameter 100 • line segment of length 1000 • If the disks are randomly placed along the segment and all intersecting placements are discarded, what positions along the line will have the highest frequency?

  9. Disk Placement: Solution • Just because the generated positions are random doesn't mean the frequencies are uniform! • Randomize the disks 1,000,000 times and keep track of valid positions • Use a histogram to visualize the densities • Or just use logic: • If you fix the leftmost and rightmost disks, then the highest probability of the disks not intersecting is if the leftmost and rightmost disks are at the extremities • Thus, the extremities should have the highest frequencies

  10. Mathematica! Histogram[Reap[Sum[l = RandomInteger[999, 5]; If[Min[Abs[Differences[Sort[l]]]] >= 100, Sow /@ l; 1, 0], {i, 1, 10000000}]][[2, 1]], 50, ChartStyle -> {EdgeForm[None]}]

  11. ~No PotW~ All problems are available at https://s3-us-west-1.amazonaws.com/gunn2013/z34pg83ucq/prXY.pdf Where X = 2, 5, or 9 (point values) and Y = 1, 2, 3, or 4 (problem numbers)

More Related