Posts

Forget Efficiency and start solving easier problems

Sometimes, you may notice that many programmers solved many problems but they made very few submissions (they are geniuses!). At first, you may think that I should try to solve the problems as less try as possible. So, after solving a problem, you will not want to try it again with other algorithm (may be far far better than the previous algorithm you used to solve that problem) to update your rank in the rank lists. But my opinion is that if you think so you are in a wrong track. You should try other ways as in that and only that way you can know that which of the algorithms is better. Again in that way you will be able to know about various errors than can occur. If you don’t submit, you can’t know it. Perhaps a problem that you solved may be solved with less time in other way. So, my opinion is to try all the ways you know. In a word, if you are a beginner forget about efficiency. Find the easier problems.Those problems are called ADHOC problems. You can find the list of those prob...

New practice session for all the programmers with me.

So guys sorry i had been missing around for a while due to academic pressure and now i promise that i will keep on updating the blog with exciting and interesting blog posts so all those who are interested to learn competitive programming from scratch can start with me.I will start posting the resources to learn the concept and some problems based on those topics.Good luck. I will  start the training from 5th june.

sorting algorithms explained part 2

Selection Sort Algorithm Selection sort algorithm starts by compairing first two elements of an array and swapping if necessary, i.e., if you want to sort the elements of array in ascending order and if the first element is greater than second then, you need to swap the elements but, if the first element is smaller than second, leave the elements as it is. Then, again first element and third element are compared and swapped if necessary. This process goes on until first and last element of an array is compared. This completes the first step of selection sort. If there are  n  elements to be sorted then, the process mentioned above should be repeated  n-1  times to get required result. But, for better performance, in second step, comparison starts from second element because after first step, the required number is automatically placed at the first (i.e, In case of sorting in ascending order, smallest element will be at first and in case of sorting in desce...

Sorting algorithm explained part 1.

Introduction to Sorting Sorting is nothing but storage of data in sorted order, it can be in ascending or descending order. The term Sorting comes into picture with the term Searching. There are so many things in our real life that we need to search, like a particular record in database, roll numbers in merit list, a particular telephone number, any particular page in a book etc. Sorting  arranges data in a sequence which makes searching easier. Every record which is going to be sorted will contain one key. Based on the key the record will be sorted. For example, suppose we have a record of students, every such record will have the following data: Roll No. Name Age Class Here Student roll no. can be taken as key for sorting the records in ascending or descending order. Now suppose we have to search a Student with roll no. 15, we don't need to search the complete record we will simply search between the Students with roll no. 10 to 20. Sorting Efficiency: There are...

How many questions, on an average basis, shall I solve daily, to become a top-level competitive programmer?

As many as you’ll manage to solve while practicing intensively instead of running for numbers. This question in fact make not too much sense. You don’t even give definition of “top-level competitive programmer”. I know people who say a coder with yellow rating is basically a stupid newbie. I know people saying that making into CF div1 means being a top-level contestant, an inspiration for everyone around. Which one fits better for your scale? You didn’t put any timetable - do you want to reach that level in a year, or two, or ten years?.. Number of problems that you solve isn’t the exact indicator of how productive you are, or how intense is your preparation, or how much new stuff you learned. There is some probability that you’ll use fixed number to motivate yourself: “I haven’t solved enough problems today, I should keep practicing instead of going to do something else”. But, on the other hand, there is decent probability that you’ll intentionally or unintentionally switch to ...

Is it possible to join ACM-ICPC with a team of 2 members only?

There must be three per team. If you have a team of only two, reach out to a third person at your university, even if their skill set is not up to your expectation. Then, train smart. In October 2016, we had an ICPC Alumni Meeting at Stanford, courtesy of Sutter Hills Ventures. It was a resounding success. One past ICPC World Finalist told of his floundering in school, seeing something about the ICPC, and joining a team of two. They accepted him only for the team to have enough members. He flourished n the team environment, where it is in everyone’s best interest for all to advance quickly. His F’s became A’s. His team advanced to the World Finals. He volunteered as a judge during a time of spectacular growth of his region. He became a trusted member of the ICPC family. He was recruited to a prominent position in Silicon Valley. He is doing well. He shared this story at the ICPC Alumni Meeting. He brought his young son who is a pistol. He knew that the ICPC family is exactly th...

Should I quit competitive programming? I am not good at it, but I like it very much?

Think about the reasons you are doing it and make a decision correspondingly. You are doing it because of some benefits you are going to get once you’ll reach decent level? Think if it is worth it - maybe you don’t have other way, or maybe you can get these benefits by doing something else and investing smaller amount of time. Or maybe you simply don’t need them. Look how much you improved over time and scale it to get some approximation on time it will take you to reach the level you want/need. You are going to improve over time. Maybe you aren’t going to improve fast. Even if you can improve quickly - it will require investing great amount of time and effort. What do you need from competitive programming? Why are you doing it? You like it very much, right? This reason sounds good enough - but you have to consider everything carefully and weight it. Just imagine that you are doing some other fun (but possibly useless) activity instead; imagine saying “Should I quit playing compute...

Which books should i use for competitive programming?

Image
One must have IMO is  Introduction to algorithms . It's huge to be honest, and gives both depth and breadth of a extensive coverage of different data structures and algorithms techniques. You may not need to study it from page to page, but use it as a reference resource. When you need to understand some topic, read that part in it, and this will give you a very solid foundation on algorithm analysis and design. Another book focus on math topic is Knuth's  Concrete Mathematics,   I believe any ambitious competitive programmer who want to do well on math problems should read this book. If you find this book a little difficult to follow, you may also try the following book which is much easy to understand.   A Friendly introduction to number theory  will teach your most of the knowledge about number theory you need in competitive programming and is extremely easy to follow. Algorithm Design by JON KLEINBERG is a book on some advanced topics on al...

level-wise breakup of competitive programming

I spent continuous 2 months of fully-dedicated work on algorithms, those were my best days, I can give advice on what felt from that time: First you need to do some good programming in string manipulation, etc., some really shortcut coding is a must, for example using C++ STL, you need to write 1 line that will give you an understanding of about 5-10 lines. This way, you ideas will flow easily, that is, you write one/two line, what you want to do is already accomplished, so understanding of the whole library you are using is mandatory like C++ STL, etc. Searching, linear & binary search are basic. Linear is too inefficient for many tasks, you will binary search in different forms in many other topics, but it is not easy to look & understand on how to apply a binary search at first, if you modify the problem slightly, you will know a binary search operation is possible. Sorting, most times, quick sort will work, rarely others are required, I used Hoare variation implem...

Good schedule to follow for becoming better at competitive programming for beginners

The three most important things in competitive programming: Learn and know your programming language. (~3 months - all the time) Learn algorithms/data structures and implement. (~9 months - all the time) Practice coding every day. Do contests. (all the time) (Doesn’t just apply to competitive programming) Have fun! (all the time) Thus, that’ll be how you break up your schedule. The time it takes for each person will differ, depending on if you already know algorithms, if you know programming or not, etc. The following is a more detailed how: #1 Learn and know your programming language. Pick a programming language and stick with it. Learn the basic syntax and start solving beginner problems. People always ask “how do you learn a programming language?” Search Google and find out; there are so many resources online. (If you really can’t find a resource, message me.) Try out USACO training pages. Or if you don't you can use the CodeChef beginner track: beginner | CodeChe...

I have solved a lot of problems say 2000 why i have not improved till now?

The number of problems solved means little. I sometimes mention it to show passion for programming (2000+ means a lot of time spent), but it says nothing about the difficulty of the problems you’ve solved. You have read a lot of problem statements and are should be comfortable in coding up solutions. Since you haven’t been progressing, you need to work smarter than you have till now. I can go to Codeforces or another online judge and solve a few hundred Div2-like problems in little time. Yet, I won’t learn anything. By now, you must know the kinds of problems you struggle with. You need to work on those. Since you’re not in Div1, my guess is that you’re not consistently solving Div2D and E problems. Focus on them. Then, move up to Div1 up to problem C. When you struggle with a problem, say graph theory, try to study up the theory behind the key ideas and consolidate your knowledge and understanding of it. Qualifying for ICPC WF is much trickier. Some regionals are way easier...

For an ACM-ICPC beginner, how should I start?

Most of the answers here point out places where one can solve problems. I'm going to describe an approach to approaching ACM programming contests which is a bit different. My definition of an ACM beginner is someone who has not done an ACM regional contest before and has essentially no competitive programming experience, so I will try to cover more of the details from starting on working ACM problems to competing in a regional contest. First, get comfortable with one of C++ and Java. You're allowed to use C, C++, or Java - using C is more likely to hinder you in the long run, so get acquainted with one of the other two languages. You should be comfortable enough with the language that you can do some simple things. In particular, you should be comfortable with the following: Reading in data from standard input (the console), or from a file. You  must learn how to do this, since that's how interaction with the program is done. Basic arithmetic operations with integer num...