Student IDs

Railways

Baggage

Bonus: Young and Successful

ACM International Collegiate Programming Contest — Training Session II C. Maria Keet Department of Computer Science, University of Cape Town, South Africa [email protected]

August 16, 2014

1 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Approach Read description What is the task? What is given? data, variables, constraints, examples

Solve the problem ‘essentially solve it’ input data space recognise underlying core issues similarity with other problems result: a solution on paper, knowing what needs to be done

solve it algorithmically (how to do it—e.g., a sort, OSPF, complexity, ...) code and test it, i.e., do it and verify solution

2 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Types of puzzles Regarding the core problem A. maths-y (e.g., probabilities, geometry) B. algorithmically/general (still an elegant solution) C. seeing patterns, and brute force

For the algorithms: which class of algorithm would be needed? i. e.g.: simple sorting, searching, graphs, numerical, combinatorial, sets, strings, geometry? ii. within the class, which type? e.g., geometry: convex hulls, range search, polygons, shape similarity, ...

The (im-)balance in the ‘what, how, do’: a. conceptually hard, but (relatively) easier to implement b. conceptually (relatively) easy, but laborious to design and/or implement c. both relatively hard (happens at the finals) d. both relatively easy (at least one puzzle in the regionals) 3 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Types of puzzles Regarding the core problem A. maths-y (e.g., probabilities, geometry) B. algorithmically/general (still an elegant solution) C. seeing patterns, and brute force

For the algorithms: which class of algorithm would be needed? i. e.g.: simple sorting, searching, graphs, numerical, combinatorial, sets, strings, geometry? ii. within the class, which type? e.g., geometry: convex hulls, range search, polygons, shape similarity, ...

The (im-)balance in the ‘what, how, do’: a. conceptually hard, but (relatively) easier to implement b. conceptually (relatively) easy, but laborious to design and/or implement c. both relatively hard (happens at the finals) d. both relatively easy (at least one puzzle in the regionals) 4 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Types of puzzles Regarding the core problem A. maths-y (e.g., probabilities, geometry) B. algorithmically/general (still an elegant solution) C. seeing patterns, and brute force

For the algorithms: which class of algorithm would be needed? i. e.g.: simple sorting, searching, graphs, numerical, combinatorial, sets, strings, geometry? ii. within the class, which type? e.g., geometry: convex hulls, range search, polygons, shape similarity, ...

The (im-)balance in the ‘what, how, do’: a. conceptually hard, but (relatively) easier to implement b. conceptually (relatively) easy, but laborious to design and/or implement c. both relatively hard (happens at the finals) d. both relatively easy (at least one puzzle in the regionals) 5 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Tips for competitive programming

General tips: Type Code Faster Quickly Identify Problem Types Do Algorithm Analysis Master Programming Languages Master the Art of Testing Code Practice and More Practice

Know your problem solving paradigms in CS: complete search, divide and conquer, greedy, dynamic programming

Competitive programming 1, by Steven and Felix Halim: https://sites.google.com/site/stevenhalim/

6 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Today

3 ICPC problems, one ‘bonus’ Problems again selected for differences in approaches, emphases what/how/do, level of difficulty If you don’t finish a problem, try at home and make sure you’ve implemented it Some sources you may want to have a look at: Steven Skiena’s “Algorithm Design Manual” Paul Zeitz’s “The art and craft of problem solving” ACM-ICPC Live Archive with hundreds of problems https://icpcarchive.ecs.baylor.edu/

7 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Outline

1

Student IDs

2

Railways

3

Baggage

4

Bonus: Young and Successful

8 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Student IDs

2013 regionals problem (see printout), many teams solved it type: algorithmically, some coding, relatively easy (in the grand scheme of things) As exercise: use aforementioned methodological steps Solve at least the ‘what’ and ‘how’-parts in 30 minutes ⇒ automata are helpful. design important to make sure you don’t miss anything.

9 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Student IDs

2013 regionals problem (see printout), many teams solved it type: algorithmically, some coding, relatively easy (in the grand scheme of things) As exercise: use aforementioned methodological steps Solve at least the ‘what’ and ‘how’-parts in 30 minutes ⇒ automata are helpful. design important to make sure you don’t miss anything.

10 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Outline

1

Student IDs

2

Railways

3

Baggage

4

Bonus: Young and Successful

11 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes

2013 regionals problem (see printout), few solved it type: algorithmically, somewhat challenging Solve it ⇒ My direction of solution is one of ‘modify existing algorithm’

12 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes

2013 regionals problem (see printout), few solved it type: algorithmically, somewhat challenging Solve it ⇒ My direction of solution is one of ‘modify existing algorithm’

13 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes: toward solution Task: second-best solution Has lots of constraints on the input data Check first example, and draw and check the second example (in the input/output files, given) Do you have to start at node 1? no. What algorithms do we have to compute trees and shortest paths? Can we use that here? OSPF/Dijkstra’s algorithm, spanning tree algorithms But can we get the 2nd-best from that? Compute OSPF for each node, take the 2nd-lowest value, or mutate lowest value? Modify a greedy algorithm for ‘second-best’: Kruskal? Prim? Which one works best? or neither, and use another solution? 14 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes: toward solution Task: second-best solution Has lots of constraints on the input data Check first example, and draw and check the second example (in the input/output files, given) Do you have to start at node 1? no. What algorithms do we have to compute trees and shortest paths? Can we use that here? OSPF/Dijkstra’s algorithm, spanning tree algorithms But can we get the 2nd-best from that? Compute OSPF for each node, take the 2nd-lowest value, or mutate lowest value? Modify a greedy algorithm for ‘second-best’: Kruskal? Prim? Which one works best? or neither, and use another solution? 15 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes: toward solution Task: second-best solution Has lots of constraints on the input data Check first example, and draw and check the second example (in the input/output files, given) Do you have to start at node 1? no. What algorithms do we have to compute trees and shortest paths? Can we use that here? OSPF/Dijkstra’s algorithm, spanning tree algorithms But can we get the 2nd-best from that? Compute OSPF for each node, take the 2nd-lowest value, or mutate lowest value? Modify a greedy algorithm for ‘second-best’: Kruskal? Prim? Which one works best? or neither, and use another solution? 16 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes: toward solution Task: second-best solution Has lots of constraints on the input data Check first example, and draw and check the second example (in the input/output files, given) Do you have to start at node 1? no. What algorithms do we have to compute trees and shortest paths? Can we use that here? OSPF/Dijkstra’s algorithm, spanning tree algorithms But can we get the 2nd-best from that? Compute OSPF for each node, take the 2nd-lowest value, or mutate lowest value? Modify a greedy algorithm for ‘second-best’: Kruskal? Prim? Which one works best? or neither, and use another solution? 17 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Designing Railway routes: toward solution Task: second-best solution Has lots of constraints on the input data Check first example, and draw and check the second example (in the input/output files, given) Do you have to start at node 1? no. What algorithms do we have to compute trees and shortest paths? Can we use that here? OSPF/Dijkstra’s algorithm, spanning tree algorithms But can we get the 2nd-best from that? Compute OSPF for each node, take the 2nd-lowest value, or mutate lowest value? Modify a greedy algorithm for ‘second-best’: Kruskal? Prim? Which one works best? or neither, and use another solution? 18 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Outline

1

Student IDs

2

Railways

3

Baggage

4

Bonus: Young and Successful

19 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage problem: sorting luggage

A 2014 finals problem (see printout), no-one solved it during the finals type: algorithmically; difficulty: judges thought it would be solved first; imho: it’s a tough nut to crack First exercise: understand the problem map the problem space (what is asked for, examples [can you find new constraints/regularities?], input space, output)

20 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: toward a solution

How to tackle the problem? I’ve heard: ‘mathsy, with some neat proofs’ brute force pattern finding It appeared to be a variation on “Taits counter puzzle”

One can prove that you need at least n moves, but that doesn’t solve the problem.

21 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: toward a solution

How to tackle the problem? I’ve heard: ‘mathsy, with some neat proofs’ brute force pattern finding It appeared to be a variation on “Taits counter puzzle”

One can prove that you need at least n moves, but that doesn’t solve the problem.

22 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: toward a solution

How to tackle the problem? I’ve heard: ‘mathsy, with some neat proofs’ brute force pattern finding It appeared to be a variation on “Taits counter puzzle”

One can prove that you need at least n moves, but that doesn’t solve the problem.

23 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: brute force

Brute force approach (thanks to SnapDragon on TopCoder): 3 ≤ n ≤ 7 is a bit of a pain (pre-compute by hand) n + 4 and larger can be done using recursion as follows:

24 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: patterns

Finding a pattern (thanks to CMK) More detail at https://keet.wordpress.com/2014/06/28/ acm-icpc-2014-solution-to-problem-a-baggage/

Approach of the algorithm: 1. move around the As and Bs to pair them as AA and BB. alternate moving AB from the right to the left, starting at the last AB (position 2n-2) and then every other 4 to its left, and BA from left to right, starting from position 3 and every other 4 positions to the right (i.e., 7, 11, etc.) 2. sort those pairs in the remainder to a total of n moves. The BBs are ferried to the right from left to right, and the AAs from the right to the left, also alternating

25 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: patterns

Finding a pattern (thanks to CMK) More detail at https://keet.wordpress.com/2014/06/28/ acm-icpc-2014-solution-to-problem-a-baggage/

Approach of the algorithm: 1. move around the As and Bs to pair them as AA and BB. alternate moving AB from the right to the left, starting at the last AB (position 2n-2) and then every other 4 to its left, and BA from left to right, starting from position 3 and every other 4 positions to the right (i.e., 7, 11, etc.) 2. sort those pairs in the remainder to a total of n moves. The BBs are ferried to the right from left to right, and the AAs from the right to the left, also alternating

26 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: patterns

Finding a pattern (thanks to CMK) More detail at https://keet.wordpress.com/2014/06/28/ acm-icpc-2014-solution-to-problem-a-baggage/

Approach of the algorithm: 1. move around the As and Bs to pair them as AA and BB. alternate moving AB from the right to the left, starting at the last AB (position 2n-2) and then every other 4 to its left, and BA from left to right, starting from position 3 and every other 4 positions to the right (i.e., 7, 11, etc.) 2. sort those pairs in the remainder to a total of n moves. The BBs are ferried to the right from left to right, and the AAs from the right to the left, also alternating

27 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Baggage: patterns

Finding a pattern (thanks to CMK) More detail at https://keet.wordpress.com/2014/06/28/ acm-icpc-2014-solution-to-problem-a-baggage/

Approach of the algorithm: 1. move around the As and Bs to pair them as AA and BB. alternate moving AB from the right to the left, starting at the last AB (position 2n-2) and then every other 4 to its left, and BA from left to right, starting from position 3 and every other 4 positions to the right (i.e., 7, 11, etc.) 2. sort those pairs in the remainder to a total of n moves. The BBs are ferried to the right from left to right, and the AAs from the right to the left, also alternating

28 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Outline

1

Student IDs

2

Railways

3

Baggage

4

Bonus: Young and Successful

29 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Young and Successful

Not an ACM ICPC problem from recent years (or at all) Description on printout Identify type Try to solve it Solve it algorithmically ⇒ Basically a version of a range search: input: A set S with n points in d-dimensional space E , and a query asking for the points in region Q

30 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Young and Successful

Not an ACM ICPC problem from recent years (or at all) Description on printout Identify type Try to solve it Solve it algorithmically ⇒ Basically a version of a range search: input: A set S with n points in d-dimensional space E , and a query asking for the points in region Q

31 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Young and Successful

Not an ACM ICPC problem from recent years (or at all) Description on printout Identify type Try to solve it Solve it algorithmically ⇒ Basically a version of a range search: input: A set S with n points in d-dimensional space E , and a query asking for the points in region Q

32 / 33

Student IDs

Railways

Baggage

Bonus: Young and Successful

Scheduled training dates

Aug 2: 9:30-15:30 Aug 16: 9:30-15:30 Aug 30: 9:30-15:30 Sept 13: 9:30-15:30 Sept 27: 9:30-15:30 Date of the regionals: 4 October, 2014

33 / 33

ACM International Collegiate Programming Contest — Training ...

Aug 16, 2014 - b. conceptually (relatively) easy, but laborious to design and/or ... Competitive programming 1, by Steven and Felix Halim: https://sites.google.com/site/stevenhalim/. 6 / 33 ... Prim? Which one works best? or neither, and use another solution? 14 / 33 .... More detail at https://keet.wordpress.com/2014/06/28/.

197KB Sizes 2 Downloads 82 Views

Recommend Documents

ACM International Collegiate Programming Contest — Training ...
Aug 16, 2014 - Student IDs. Railways ... Contest — Training Session II. C. Maria Keet. Department of Computer Science, University of Cape Town, South Africa.

ACM International Collegiate Programming Contest — Training ...
Aug 30, 2014 - Identifying a CS 'problem-solving paradigm' from the ... content in this section based on “Competitive programming 1”, by Steven and Felix ...

ACM International Collegiate Programming Contest — Training ...
Aug 30, 2014 - Contest — Training Session III. C. Maria Keet. Department of Computer Science, University of Cape Town, South Africa [email protected].

ACM International Collegiate Programming Contest — Training ...
Aug 16, 2014 - Department of Computer Science, University of Cape Town, South Africa ..... BA from left to right, starting from position 3 and every other.

The 13th ACM Arab Collegiate Programming Contest
If you need an AZERTY keyboard during the contest, you must bring one with you. Label it with your team's name. Once in Beirut: 1. Enter the LAU campus from ...

Problem Solving Strategies - ACM International Collegiate ...
Your first task is to write a program that identifies the maximum possible gain out ... that cockroaches (of the 7cm long and 1.3cm thick type) like that weather too!

ACM ICPC Greater New York Region Contest -
... will provide a space for about 150 motivated college students from the New York ... The top teams from this contest will be invited to compete in the 2017 ACM ICPC ... Each member of the organizing team has been involved in programming ... Reserv

ACM ICPC — Training Session IV - UCT
Sep 13, 2014 - Task: calculate time it takes to arrive home (≤24h), or impossible. Linear search to crunch through the segments and update, or binary search ...

History-Of-Programming-Languages-Acm-Monograph-Series.pdf ...
Retrying... Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. History-Of-Programming-Languages-Acm-Monograph-Series.pdf. History-Of-Programming-Langua

Script: International/Humorous Speech Contest Master
The script below is a suggested outline of the main points that need to be covered. ... to all. o To provide an opportunity to learn by observing the more proficient ...

ACM and ACM-W Schedule -
Karen Shanklin, Courtney Brazell, and Kristijana Arroyo will talk about their experiences at. Sandia, the Jill Hruby Fellowship, and the open source wave energy converter array simulation tool, SWAN. Female students are strongly encouraged to attend.

ANNOUNCEMENT International Symposium & Training ... - whitrap
Dec 10, 2014 - Email: [email protected] .... I also declare that, to the best of my ... If you register by email, please attach the electronic signature.

Problem Solving Strategies – set of problems - ACM International ...
Sample output. Case 1. C 7. B 22. A 37. Case 2. E 0. A 1. D 1. C 10. B 50. 5 .... Figure 2: Illustration for the antennas and coverage. Write a program that finds the ...

2012 IEEE/ACM International Conference on Advances in Social ...
Link and Node Analysis of Gender Based Collaborations in Turkish Social .... Link Prediction for Bipartite Social Networks: The Role of Structural Holes .

An International Contest for Graduate Students THE GENEVA ...
Dec 8, 2017 - to an independent high level Jury Panel composed of policy makers and academics, young talents and experienced professionals, who will select the competition's finalists. 4.4. In the third and last phase of evaluations, one finalist per

2016 International Mind Education Specialist Training IYF.pdf ...
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item.

ANNOUNCEMENT International Symposium & Training Course on the ...
Dec 10, 2014 - All correspondence concerning the Training Course or the .... Please complete this form by computer and email to [email protected] or.

Kofi Annan International Peacekeeping Training Centre ... - WACSI
The overall objective of the course is to equip participants with effective tools for analytical thinking, leadership and other critical managerial skills in Gender, ...

Cochrane Collegiate Academy.pdf
Robinson Church Rd. Barrington Dr. Shamrock Dr. Linda Lake Dr. Central Av. Hickory Grove Rd. Ruth Dr. Farm Pond Ln. Hood Rd. Williams Rd. Tipperary Pl ... Terry Ln. Grafton Dr. Lake Forest Rd East. Dale Av. Marlwood Cr. Woodgreen Tr. Falstaff Dr. Wil

practice - ACM Digital Library
This article provides an overview of how XSS vulnerabilities arise and why it is so difficult to avoid them in real-world Web application software development.

Jana Vignana Vedika National Short Film Contest, JVV Contest 2018 ...
Jana Vignana Vedika National Short Film Contest, JVV Contest 2018 Application.pdf. Jana Vignana Vedika National Short Film Contest, JVV Contest 2018 Application.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Jana Vignana Vedika Nationa