130 likes | 279 Views
break;. return; // to school :’(. PotW Solution. Problem recap: Write a Befunge program that prints out a Brain**** program that prints out a HQ9+ program that prints out “Hello, world !”. HQ9+ program output by Brain**** program is “H”
E N D
break; return; // to school :’(
PotW Solution • Problem recap: Write a Befunge program that prints out a Brain**** program that prints out a HQ9+ program that prints out “Hello, world!”. • HQ9+ program output by Brain**** program is “H” • Brain**** program output by Befunge program may be ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. (including the dot at the end; there are different ways to write this program but this is the simplest) • Many ways to approach Befunge program
Example Solutions • 20 characters (Andrew Wang) 89* v ,"+"-1_v#:< " . " , @ • 19 characters (Tony Jiang) 89*>: v ^ , "+"-1_".",@ • 13 characters (Steven Hao) "#>56++v ,:| > @
Announcements • ProCo on May 26, 8AM – 5PM • Registration is “temporarily full” until more space is found, but there’s a waiting list you can sign up for at http://proco.stanford.edu. • US Open/USACO results • Congratulations to Steven Hao and Johnny Ho for placing 2nd and 3rd in the country for US Open Gold division! • Lynbrook students did very well in this year’s overall USACO rankings! (Johnny Ho 1st in Gold, Steven Hao 9th in Gold, MG Chi 19th in Gold, QingqiZeng 2nd in Silver, Karen Ouyang 4th in Silver, Julia Huang 18th in Silver) • Kudos to everyone who consistently participated in USACO this year! • USACO Finalists • Special congratulations to Steven Hao for qualifying for the USACO camp! • Oh, and Johnny too.
Officer Applications • This year’s officer application will be made available today! • Check the website (http://lynbrookcs.com); also will be emailed • Due on Monday, May 14 at 11:59:59 PM • Results will be announced on Monday, May 23 • Same officer positions as this year: • 1 president • 1 vice president • 1 secretary • 1 treasurer
US Open Let’s have a look at some of the problems!
Bronze – Three Lines • Given a set of up to n <= 50000 cows on the X-Y plane with integer coordinates, determine if it is possible to cover all the cows with three horizontal or vertical lines. • Create “histogram” of how many times each distinct y-coordinate appears as well as how many distinct y-coordinates there are • Coordinates may have to be “compressed” first: normalize the coordinates to be within the range [0, N) (or use HashMap) • Check 4 cases of what points can be covered by: • 3 horizontal lines: Passes if number of distinct y-coordinates is as most 3 • 2 horizontal, 1 vertical: Sort points on x, for each distinct x-coordinate remove all points with that x-coordinate (simulating vertical line there), test if number of distinct y-coordinates drops to at most 2 • Other two cases identical to these two, except swap “x” and “y”
Silver – Unlocking Blocks • Given the shapes and locations of three objects (represented as series of the coordinates for the individual boxes that form the shapes), determine the minimum number of slides (one object moved one tile north, east, south, or west) needed to separate the blocks (bounding boxes no longer overlap).
Silver – Unlocking Blocks • Use depth/breadth-first search: find path from initial state to state w/ disjoint bounding boxes • Since we are not looking for any particular path, any of these graph search algorithms works • Represent state with 4 integers (x and y offsets of objects 2 and 3 from their original positions) • Each move consists of adding/subtracting 1 from one of these numbers, or adding/subtracting 1 from both x-coordinates or both y-coordinates (representing object 1 being moved) • DFS/BFSmay quickly branch out but objects and coordinates are small so it’s okay
Gold – Tied Down • Given n <= 10 poles stuck in the ground and a string that wraps around them, find the minimum number of poles that must be removed before the string can be untangled • Obviously, the string cannot pass through poles unless they are removed • The poles are conveniently all on the same line (same x-coordinate) • Try removing all 210 subsets of the poles • Find y coordinates of intersections between the string and the line • Use a stack to simplify the crossings as you traverse the string • If a string crosses across one portion of the line and then immediately returns across the same portion, the string will then unwrap • If the stack is completely emptied by the time the entire string has been traversed, the string can be untangled
PotW • No PotW this week – study for AP exams if you’re taking any! (or finish that AP Lit research paper…) • The Befunge problem marks the last PotW of this school year (or does it?)