Getting Started: Difference between revisions
imported>Kmk21 Created page with "So you want to do programming contests but don't know where to start? Well, it seems you do....since you're, well, here. =Contests= Contests come in many shapes and sizes. He..." |
imported>Kmk21 No edit summary |
||
Line 7: | Line 7: | ||
The international collegiate programming contests is the largest contest for college programmers. It consists of two levels: regionals and world finals. We compete in the mid-atlantic regional. Generally the top two to three teams from each region are invited to world finals (though they can't be from the same school). World finals are often held in exotic places such as Phuket and Banf. | The international collegiate programming contests is the largest contest for college programmers. It consists of two levels: regionals and world finals. We compete in the mid-atlantic regional. Generally the top two to three teams from each region are invited to world finals (though they can't be from the same school). World finals are often held in exotic places such as Phuket and Banf. | ||
===Contest Environment=== | ===Contest Environment=== | ||
For these contests you have teams of three individuals, but just ONE computer. There are generally 8-13 problems to solve in the 5 hours. Problems will always describe some sort of problem whose output will vary based on some input. While you are given some sample input and output, whether your algorithm is deemed "correct" is based on secret input that you are NOT given. Instead, you must submit your code, where a "judge" (i.e. some server running somewhere) will run your code against the secret input and compare your output with the correct secret output. Only if you get the secret output exactly correct will your submission get correct. Submissions must be in Java, C, or C++. | For these contests you have teams of three individuals, but just ONE computer. There are generally 8-13 problems to solve in the 5 hours. Problems will always describe some sort of problem whose output will vary based on some input. While you are given some sample input and output, whether your algorithm is deemed "correct" is based on secret input that you are NOT given. Instead, you must submit your code, where a "judge" (i.e. some server running somewhere) will run your code against the secret input and compare your output with the correct secret output. Only if you get the secret output exactly correct will your submission get correct. Submissions must be in Java, C, or C++. Oh, and by the way, it has to run fast enough! Generally they tell you what the time limit is, but with practice, you'll know if a solution is fast enough by analyzing your algorithm vs the maximum size of the input. | ||
===Input and Output=== | ===Input and Output=== | ||
You must write a standalone program (it will have a "main" method) which reads from standard input and writes to standard output. | You must write a standalone program (it will have a "main" method) which reads from standard input and writes to standard output. | ||
Line 18: | Line 18: | ||
Codeforces is one of the best regular contests to help prepare you for ICPC. Their contests are run almost exactly the same as ICPC, but with individuals instead of teams. Keep an eye out for them, and know that you often have to register before the round starts. You will start in division 2, and will be promoted to division 1 when your ranking is high enough. | Codeforces is one of the best regular contests to help prepare you for ICPC. Their contests are run almost exactly the same as ICPC, but with individuals instead of teams. Keep an eye out for them, and know that you often have to register before the round starts. You will start in division 2, and will be promoted to division 1 when your ranking is high enough. | ||
==[https://www.topcoder.com/community/competitive-programming/ Topcoder] | ==[https://www.topcoder.com/community/competitive-programming/ Topcoder]== | ||
Topcoder is another hoster of regular contests. Their Single Round Matches (SRMs) are quick ways to practice. | Topcoder is another hoster of regular contests. Their Single Round Matches (SRMs) are quick ways to practice. | ||
===Contest Environment=== | ===Contest Environment=== | ||
Line 35: | Line 35: | ||
==Writing your First Solution== | ==Writing your First Solution== | ||
The first thing I do when I solve ANY problem (literally...any problem) is start with my template. It looks like this | The first thing I do when I solve ANY problem (literally...any problem) is start with my template. It looks like this (for problem "a" from a set). Your template may vary slightly, but I recommend starting all your problems the same way! Just getting over the hump of getting SOMETHING down helps you get started. | ||
<syntaxhighlight line lang="java"> | <syntaxhighlight line lang="java"> | ||
import java.util.*; | import java.util.*; | ||
Line 50: | Line 50: | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
==Input and Output== | ==Input and Output== | ||
We have a great tutorial on [[Input and Output]]. It will be the first thing | We have a great tutorial on [[Input and Output]]. It will be the first thing you have to do when writing your program. Without a great tutorial, I found it very frustrating, and often spent so much time on it I didn't even get to the algorithm! But heed the advice in the guide. I also recommend reading the input before necessarily thinking about how you will solve the problem, since how you solve the problem should have no bearing on how you read the input! In any case, the problems in the trivial set shouldn't have enough algorithmic complexity, so you should be able to just focus on getting some correct solutions. | ||
Generally output is pretty easy, just printing single numbers, or each element in an array. Become familiar with printf (also in the tutorial), as it will be your friend! Sometimes you end up with rather complicated output. This is annoying, and some of the cases you will get better at handling with practice (such as printing out a path through a graph). | |||
==Do Stuff== | |||
This is the meat of the problem. This is what will challenge you once you move past the trivial problems. Hopefully through participating in programming contests you will learn new algorithms and data structures, and more importantly, be able to apply them to unknown problems. It turns out that skill is a MAJOR boost in coding interviews, as the problems and techniques you get are incredibly similar to what you might see in a programming contest. | |||
=Getting Better= | |||
If you head over to [:Category:Tutorials:Tutorials] |
Revision as of 08:14, 29 August 2016
So you want to do programming contests but don't know where to start? Well, it seems you do....since you're, well, here.
Contests
Contests come in many shapes and sizes. Here are some of them
ICPC
The international collegiate programming contests is the largest contest for college programmers. It consists of two levels: regionals and world finals. We compete in the mid-atlantic regional. Generally the top two to three teams from each region are invited to world finals (though they can't be from the same school). World finals are often held in exotic places such as Phuket and Banf.
Contest Environment
For these contests you have teams of three individuals, but just ONE computer. There are generally 8-13 problems to solve in the 5 hours. Problems will always describe some sort of problem whose output will vary based on some input. While you are given some sample input and output, whether your algorithm is deemed "correct" is based on secret input that you are NOT given. Instead, you must submit your code, where a "judge" (i.e. some server running somewhere) will run your code against the secret input and compare your output with the correct secret output. Only if you get the secret output exactly correct will your submission get correct. Submissions must be in Java, C, or C++. Oh, and by the way, it has to run fast enough! Generally they tell you what the time limit is, but with practice, you'll know if a solution is fast enough by analyzing your algorithm vs the maximum size of the input.
Input and Output
You must write a standalone program (it will have a "main" method) which reads from standard input and writes to standard output.
Ranking
Teams who solve the MOST problems in the 5 hours are the winners. Tie breaking is done by your total penalty time, which is calculated as follows
- For any problem you solved, the number of minutes that have elapsed since the start of the contest when you solved it are added
- For any problem you solved, 20 minutes are added for each INCORRECT submission BEFORE you got the problem solved correctly
Codeforces
Codeforces is one of the best regular contests to help prepare you for ICPC. Their contests are run almost exactly the same as ICPC, but with individuals instead of teams. Keep an eye out for them, and know that you often have to register before the round starts. You will start in division 2, and will be promoted to division 1 when your ranking is high enough.
Topcoder
Topcoder is another hoster of regular contests. Their Single Round Matches (SRMs) are quick ways to practice.
Contest Environment
For these contests, you launch their "arena" and assuming you have registered for the contest, are placed in a room with ~20 other coders. When the contest starts, each of the three problems will be visible. When you open one, you will provided with a text editor. There is nothing stopping you, however, from using whatever editor you choose and copying the code in. Once you put the code in, you can compile and run a few example test cases to see if they pass, and finally submit. UNLIKE ICPC, however, you will not get your result. For now Topcoder will ASSUME your answer is correct and award you the points.
Challenge Phase
Once the coding phase has ended, you enter the challenge phase. Here you can look at the solutions of other people in your room. If you think they made a mistake, you can "challenge" their solution by providing an input you think their code will get wrong. You get points if you are correct, or lose them if you are not. Only one person can successfully challenge an incorrect solution, so be quick!
System Test
Lastly, the "judge" will run all the solutions against secret test cases, removing points which were awarded if the solution was deemed incorrect.
Ranking
Problems are each worth different point values (generally 250, 500 and 1000). When you FIRST open a problem, the clock starts ticking, and the more time you take to solve that problem is deducted from the amount of points it is worth. So if you end up taking a long time to solve the first problem, you might only get 150 points. At the end of the contest, your points from solutions (which passed system test) and from challenges are added, and the person with the most wins.
Input and Output
You are generally provided with a method signature which you must implement. You will not need a "main" function for these, as your code will just be included by some other program. The input will be the method parameters, and the output will be the return.
Starting to Practice
If you have NEVER solved a problem before, you're probably going to want to start with Kevin's trivial set. There you will find problems (which come from REAL CONTESTS) which will help you get your feet wet. You will need a login, so ask kevin for one.
Writing your First Solution
The first thing I do when I solve ANY problem (literally...any problem) is start with my template. It looks like this (for problem "a" from a set). Your template may vary slightly, but I recommend starting all your problems the same way! Just getting over the hump of getting SOMETHING down helps you get started.
import java.util.*;
public class a {
Scanner in=new Scanner(System.in);
public static void main(String[] args) {
new a().go();
}
private void go() {
// read input
// do stuff
// print output
}
}
Input and Output
We have a great tutorial on Input and Output. It will be the first thing you have to do when writing your program. Without a great tutorial, I found it very frustrating, and often spent so much time on it I didn't even get to the algorithm! But heed the advice in the guide. I also recommend reading the input before necessarily thinking about how you will solve the problem, since how you solve the problem should have no bearing on how you read the input! In any case, the problems in the trivial set shouldn't have enough algorithmic complexity, so you should be able to just focus on getting some correct solutions.
Generally output is pretty easy, just printing single numbers, or each element in an array. Become familiar with printf (also in the tutorial), as it will be your friend! Sometimes you end up with rather complicated output. This is annoying, and some of the cases you will get better at handling with practice (such as printing out a path through a graph).
Do Stuff
This is the meat of the problem. This is what will challenge you once you move past the trivial problems. Hopefully through participating in programming contests you will learn new algorithms and data structures, and more importantly, be able to apply them to unknown problems. It turns out that skill is a MAJOR boost in coding interviews, as the problems and techniques you get are incredibly similar to what you might see in a programming contest.
Getting Better
If you head over to [:Category:Tutorials:Tutorials]