Download presentation

Presentation is loading. Please wait.

Published byRickey Enix Modified over 3 years ago

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 o Life is tough. Deal with it. o 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 o Break ties by choosing the leftmost segment/seat E.g. N = 4 and K = 3 o _ _ _ _ o _ o _ _ o _ 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 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 { 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 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 o Use a histogram to visualize the densities Or just use logic: o 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 o 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/pr XY.pd f Where X = 2, 5, or 9 (point values) and Y = 1, 2, 3, or 4 (problem numbers)

Similar presentations

OK

Analysis of Simulation Results Chapter 25. Overview Analysis of Simulation Results Model Verification Techniques Model Validation Techniques Transient.

Analysis of Simulation Results Chapter 25. Overview Analysis of Simulation Results Model Verification Techniques Model Validation Techniques Transient.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Detail ppt on filariasis disease Ppt on solar powered cars Ppt on history of olympics Ppt on marketing management download Ppt on waxes definition Ppt on components of railway track Download ppt on save fuel Ppt on wireless mesh networks Slides for ppt on pollution of air Ppt on street play in hindi