1 / 23

ACM-HK - Collegiate Programming Contest (ACM-HK CPC)

ACM-HK - Collegiate Programming Contest (ACM-HK CPC). Tutorial 1 Introduction. Information about the documents. ftp://ftp.must.edu.mo user name: hndai_stu password: dkysf6rs. Outline. 1. Program 2. Time and Venue 3. Regulations 4. Brief intro 5. Tips. Program of ACM-HK CPC 201 4.

Télécharger la présentation

ACM-HK - Collegiate Programming Contest (ACM-HK CPC)

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. ACM-HK - CollegiateProgramming Contest (ACM-HK CPC) Tutorial 1 Introduction

  2. Information about the documents • ftp://ftp.must.edu.mo • user name: hndai_stu • password: dkysf6rs

  3. Outline • 1. Program • 2. Time and Venue • 3. Regulations • 4. Brief intro • 5. Tips

  4. Program of ACM-HK CPC 2014 • 10:45-11:15 Registration • 11:15-12:00 Preparation and testing of machines • 12:00-13:40 Lunch time • 13:40-13:50 Competition Preparation • 13:50-14:00 Openning speech • 14:00-18:00 Competition • 18:30-21:30 Banquet and Award Ceremony This information is based on the previous contest

  5. 2. Time and Venue • 28 June, 2014 • The Open University of Hong Kong

  6. 3. Regulations • Competing against the clock. • Software: Dev C++ 4.9.9.2, Microsoft Visual Studio 2010, Oracle JDK 7 (based on Microsoft Windows 7) • Language: C, C++, Java and Pascal • Each team is given 6 programming problems within 4 hours. • The team that correctly solves the most problems wins. • If multiple teams solve the same number of problems, the team that solved them fastestwins. Expertise in quick-and-dirty hacking is usually more valuable than rigid software engineering techniques in such an environment. Experience with debugging stupid mistakes is also a plus.

  7. 3. Regulations (continue) • There are judges who will determine whether your program passed the testing cases. • You can ask the judges questions. • Note that you shall consider all the possible testing cases instead of only given ones. • You can bring any documents related to the contest (books, printed algorithms, programs). But, all of them need to be hard copies, NOT e-copies. None e-devices are allowed to use.

  8. 4. Brief intro of ACM-CPC • Every year, the Association for Computing Machinery (ACM) sponsors regional and international collegiate programming contests (CPC). • They divide the world up into 16 regions. • Each region has a regional contest, with the top two or three teams in each region going on to the international contest.

  9. What is the benefit of participating programming contests? • Many IT companies, and some best trading companies and hedge funds in finance, prefer students that are competitive in algorithms, programming, and math. • Many students who have experience in ICPC get the best offers from Google, Facebook, and Microsoft. • The skills learned in programming contests not only help you find a good job, but also make you technically component in all areas that are related to computers. • Most importantly, solving programming problems is fun.

  10. How to prepare team selection contest? • Solve problems at Online Judges. • 1. USACO Training Gateway, http://acm.hdu.edu.cn/for starters. • 2. Codeforces, Topcoder, and POJ to practice on more problems. Coderforces and Topcoder also have solutions to their problems.

  11. Ability to quickly identify problem types • In all programming contests, there are only three types of problems: • I haven't see this one before • I have seen this type before, but haven't or can't solve it • I have solve this type before • The ability to quickly identify problems into the above mentioned contest classifications (haven't see, have seen, have solved) will be one of key factor to do well in programming contests.

  12. Techniques you may use • Mathematics • Dynamic Programming • Graph • Sorting • Searching • String Processing • Greedy algorithms

  13. Ability to analyze your algorithm • You have identified your problem. You think you know how to solve it. • Given the maximum input bound (usually given in problem description), can my algorithm, with the complexity that I can compute, pass the time limit given in the programming contest? • Usually, there are more than one way to solve a problem. However, some of them may be incorrect and some of them is not fast enough. Brainstorm many possible algorithms - then pick the stupidest that works!

  14. Things to learn about algorithms • Proof of algorithm correctness (especially for Greedy algorithms) • Time/Space complexity analysis for non recursive algorithms. • For recursive algorithms, the knowledge of computing recurrence relations and analyze them: iterative method, substitution method, recursion tree method • Analysis of randomized algorithm which involves probabilistic knowledge, e.g: Random variable, Expectation, etc. • Output-sensitive analysis, to analyze algorithm which depends on output size

  15. Table 1: Time comparison of different order of growth We assume our computer can compute 1000 elements in 1 seconds (1000 ms)

  16. Some tips • Biggest built in data structure "long long" is 2^63-1: 9*10^18 (up to 18 digits) • If you have k nested loops running about n iterations each, the program has O(n*k) complexity • If your program is recursive with b recursive calls per level and has l levels, the program O(b*l) complexity • Bear in mind that there are n! permutations and 2^n subsets or combinations of n elements when dealing with those kinds of algorithms • The best times for sorting n elements are O(n log n) • DP algorithms which involves filling in a matrix usually in O(n^3) • In contest, most of the time O(n log n) algorithms will be sufficient.

  17. The art of testing your code • No partial right answer • In ACM ICPC, you will only get credit if your team's code solve all the test cases, that's it, you'll get either Accepted or Not Accepted (Wrong Answer, Time Limit Exceeded, etc). • Sample input-output given in problem description is by default too trivial and therefore not a good way to measure your code's correctness for all input instances. • One way to test your code: ask your teammates to write some test cases.

  18. Designing good test cases: • Must include sample input, the most trivial one, you even have the answer given. • Must include boundary cases, what is the maximum n,x,y, or other input variables, try varying their values to test for out of bound errors. • For multiple input test case, try using two identical test case consecutively. Both must output the same result. This is to check whether you forgot to initialize some variables, which will be easily identified if the first instance produce correct output but the second one doesn't. • Increase the size of input. Sometimes your program works for small input size, but behave wrongly when input size increases.

  19. Designing good test cases: (cont.) • Tricky test cases, analyze the problem description and identify parts that are tricky, test them to your code. • Don't assume input will always nicely formatted if the problem description didn't say so. Try inserting white spaces (space, tabs) in your input, check whether your code is able to read in the values correctly • Finally, do random test cases, try random input and check your code's correctness

  20. Other tips • Good management of your time • Read through all the questions • Order the problems and choose the easiest one to solve first • Sketch the algorithms, complexity, the numbers, data structures, tricky details. • Brainstorm other possible algorithms • Do the Math! • space & time complexity & plug-in actual expected & worst case numbers • Code it as fast as possible • Try to break the algorithm – test it.

  21. How to test your answers • Several online robots: • http://www.programming-challenges.com (online forms) • http://online-judge.uva.es (emails submissions) • Some UVa Online Judge Problemset Hints • USACO Training Gateway • http://acm.hdu.edu.cn/ • Codeforces, Topcoder, and POJ • Register an account first

  22. Reference e-books • Steven S. Skiena Miguel A. Revilla, Programming Challenges - The Programming Contest Training Manual • Ahmed Shamsul Arefin, Art of programming contest • 算法艺术与信息学竞赛:算法竞赛入门经典 • 图灵程序设计丛书:挑战程序设计竞赛(第2版)

  23. Questions for tutorial 1 • The 3n+1 problem (pp.15) • Minesweeper (pp.16) • The Trip (pp.17) • LCD Display (pp. 18) • Graphical Editor (pp. 19) • Interpreter (pp. 21) All from reference book: Programming Challenges - The Programming Contest Training Manual

More Related