Presentation is loading. Please wait.

Presentation is loading. Please wait.

Boolean lessThanThree; Defaults to false.. PotW Solution - Compression int dp(int i, int cnt) { if (cnt > lim) return (1 << 29); if (i == n) return 0;

Similar presentations


Presentation on theme: "Boolean lessThanThree; Defaults to false.. PotW Solution - Compression int dp(int i, int cnt) { if (cnt > lim) return (1 << 29); if (i == n) return 0;"— Presentation transcript:

1 boolean lessThanThree; Defaults to false.

2 PotW Solution - Compression int dp(int i, int cnt) { if (cnt > lim) return (1 << 29); if (i == n) return 0; if (mem[i][cnt] != -1) return mem[i][cnt]; mem[i][cnt] = 1 << 29; for (int j = i + 1; j <= n; ++j) { int mid = (i + j) / 2, sum = 0; for (int k = i; k < j; ++k) { sum += abs(arr[k].val - arr[mid].val); } int poss = sum + dp(j, cnt + 1); if (poss < mem[i][cnt]) { mem[i][cnt] = poss; next[i][cnt] = j; } return mem[i][cnt]; } Full source code at http://ideone.com/iC4F6!http://ideone.com/iC4F6

3 Harker Invitational! March 17th, 8:30am - 3:30pm Like Gunn and other ProCo-likes o Teams of up to 3 compete in a 1.5 hour round, submit answers online, etc. o ~APCS-level problems There will be prizes! (no idea what they are though) o And PotW credit! There will also be a half-hour challenge round o Individuals who complete the challenge problem are entered into a raffle for a $300 Silicon Valley Driving School gift certificate Register at http://bit.ly/harkerproco12http://bit.ly/harkerproco12

4 Harker Invitational (cont.) Tentative 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

5 Reminders! Gunn Programming Contest is Feb. 25, 9AM – 3PM o During break! o Register at http://bit.ly/gunnproco12http://bit.ly/gunnproco12 Stanford ProCo is May 19 o Details TBA

6 About ProCo-likes Cooperation, time management are key o Typically only one laptop per team allowed for coding o Write your programs correctly the first time! Problems divided into 3 difficulty levels: 2, 5, and 9- point problems o 2-point problems are typically quite trivial/straight-forward o 5-point problems take some thinking/planning (about bronze-silver USACO level) o 9-point problems can be quite challenging (at or a little below USACO Gold level?) Find the most efficient way for your team to divide up the problems!

7 Harker 2011 #2.1: “Jaded J’s” Print out the first seven presidents of the United States. Sample input: Not applicable Sample output: George Washington John Adams Thomas Jefferson James Madison James Monroe John Quincy Adams Andrew Jackson

8 #5.4: “Wordy Wordsearch” Given a 10x10 matrix of lowercase characters, and a list of 10 words (1-10 characters), for each word output “yes” if the word is found in the word search and “no” if it isn’t. Sample input:Sample output: aaaaaaaaaayes bbbbbbbbbbyes ccccccccccyes ddddddddddyes eeeeeeeeeeyes aaaaaaaaaayes bbbbbbbbbbyes ccccccccccyes ddddddddddyes eeeeeeeeeeyes a ab abc abcd abcde e ed edc edcb edcba

9 Wordy Wordsearch (cont.) Simply search (in all 8 directions) o Implementation is trickier than coming up with the method itself Store wordsearch in a 2D array Iterate through characters and compare to first letters of each word in list Check in 8 directions each time you find a potential start of a word o Might be useful to use nested for-loops with “xDir” and “yDir” looping from -1 to 1, skip xDir==0 && yDir==0 case, to save lines of code

10 PotW – Who’s the Boss? ( Harker Invitational 2011) Determine the ancestors of a node in an organization graph. Given a list of employee to boss relationships and a list of queries, determine which of the queries must be satisfied. Each organizational line is composed of one team: the first element will be the number of employees in the group, the first name will be the boss, and each following name will be the direct employees. Each query is composed of two people: X and then Y. Determine if X must obey Y. The input is guaranteed to be valid: there will be no cyclic relationships, and all names will correspond properly. # of employees < 1000 # of queries < 1000 Worth 25 points

11 Who’s the Boss? (cont.) Sample Input: 4 (# of groups) 2 BigBoss Amy Fred 3 Amy Wilson Stoker Bubba 4 Wilson James Marc Tim Alan 2 Fred Wilma Dino 3 (# of queries) Alan Dino Alan BigBoss Wilson James Sample Output: no yes no


Download ppt "Boolean lessThanThree; Defaults to false.. PotW Solution - Compression int dp(int i, int cnt) { if (cnt > lim) return (1 << 29); if (i == n) return 0;"

Similar presentations


Ads by Google