Figuring Out Competitive Coding

News, 17th January 2018

Competitive coding is something that everyone is recommended to try out during his/her initial years at college. Its close affinity to logical reasoning and mathematics makes it one of the most followed hobbies at campus. While a lot of the starters give up once the initial motivation dies, a few take it to an all new level garnering laurels not only at the national but at the international level, as well. Over a gloomy Friday afternoon, we hung out with Adarsh Kumar, Saharsh Luthra and Vaibhav Gosain (from left to right), who easily qualify as one among the best competitive coders of the campus, and discussed with them about their journeys in competitive coding, ICPC and a lot more.


GG: The three of you have participated in various competitions and excelled in most of them. What is your most profound memory from any of these competitions?

Saharsh: It was during my second year that I took part in a contest organised by IIIT Hyderabad. The contest focussed mainly on mathematical problems. A lot of people participated and amongst them was a guy called Gennady Korotkevich, one of the best competitive coders in the world—a prodigy. The great thing was that I gave him tough competition and was beaten by just one problem. I came first in India and that too with a great margin. That was one of the best moments for me.

Vaibhav: For me, the exceptional moments are when I perform very poorly in a contest or if something funny happens. One such instance was during the 2015–16 Chennai Regionals. After a series of wrong solutions, we had lost all our hopes of cracking one of the easiest problems in the contest. In the last minute, we made one final change to our solution but didn’t bother to submit it. Luckily for us, one of our teammates stayed back and pushed the submit button. That was one of the most unexpected correct answers that we had got and the incident still remains fresh in my memory.


GG: How did your journey in competitive coding begin and did you face any major difficulties?

Vaibhav: When I came to IIT Roorkee, I used to interact with my seniors in search of things to explore in Computer Science. In our first year, there was a great hype around competitive coding. Going with the wind, I too started doing it. Initially, it took me ten-fifteen attempts to solve even the basic problems. But soon, I developed an interest in it. I started out by solving problems on SPOJ, then I moved onto CodeChef and CodeForces.


GG: What is the importance of having a good community when we talk in context of competitive programming?

Adarsh: A coding community plays a very important role. It gives you the liberty to discuss new problems, unknown concepts and much more. For me, I knew Saharsh, who a had deep interest in mathematics and I could ask him any doubt. Apart from that, it also creates a healthy competitive environment which motivates you to perform. One can always find people to look up to. China and Russia are the strongest countries when it comes to competitive programming. Many of their high school students perform better than us. This, essentially, is because of a different coding culture prevalent in these countries which is somewhat unrelatable to us. Competing with coders from these countries is generally difficult because of the same reason.


GG: Tell us about one course that you have taken in IITR and which should be taken by every mathematics and competitive coding enthusiast?

Saharsh (instantly): Discrete Mathematics.

Adarsh: I did not have a course on Discrete Mathematics in Mechanical. I had to study it from different sources and master the concepts by solving questions on different online judges. Discrete mathematics forms a base for many important mathematical concepts.


GG: You all must have come across many algorithms, theorems, and data structures. So, which one appeals to you the most?

Adarsh: The Fourier Transform. It solves a naive problem with a very different approach. The Fourier Transform finds a beautiful way of multiplying two polynomials using complex numbers which is pretty cool. That’s quite intriguing for me.

Saharsh: For me, it would be a data structure called Segment Tree. It is simple but at the same time very interesting. The speciality of this data structure is that it has a wide range of applications, and it is very feasible to use.

Vaibhav: Well, I have a list of favourite algorithms. Centroid Decomposition is one of them. It became famous in competitive programming very recently, thus currently it’s at the top of my list.


GG: Moving on to the ICPC, you guys nearly made it to the world finals last year. So how was your experience there?

Adarsh: There were seven problems in the online round. The first five problems were relatively easy and we solved them like many others, but we got penalties that made us miss the top positions. However, the last two problems were comparatively difficult, and only a handful of people were able to solve them. We started thinking about them and a crack came with around half an hour left in the contest. In the final ten minutes, we submitted the solutions but the CodeChef server was very busy and our codes were in the queue. We were not getting any verdict. Even if we had got a wrong answer or TLE, we could have tried correcting it but, we were helpless. Then, all of sudden, our sixth problem got accepted and in a few minutes, our last submission turned out to be correct as well. Only five teams in India could solve all the problems and we were one among them. Now, Vaibhav will tell you about our experience in the Regionals.

Vaibhav: In one word, the entire experience was frustrating. Kharagpur Regionals, which was the first one, turned out to be one of our worst performances. We ended up at the twelfth position and it was quite disappointing for us. The interesting part, though, was that the team which was on the top of the leaderboard gave one of the best performances in the history of ICPC. The next in line was the Kolkata Regionals which went well and we ended up ranking third. Still, we had no hopes of qualifying for the world finals. We gave the India final and we were ranked sixth. We made it to the verge of qualifying for the world finals but we couldn’t make it through.


GG: The three of you complement the skills of each other and have come out as a very strong team. What suggestion you have for young competitive coders who are looking to form that perfect team?

Saharsh: One of the mistakes that beginners make is that they try to team up with the best players without considering team coordination. Coordination is the key factor. Sometimes while solving a problem, half of the solution is done by one while the other half by someone else. So one should try teaming up with people one is comfortable with and not just run behind the big names.

Vaibhav: Practicing together also matters. You get to know how the other person approaches a problem, in which type of problem the other is more comfortable and it also strengthens team bonding.


GG: Finally what’s your message for the beginners in competitive programming, basically the freshers and the sophomores on how to have a head start and develop a proper approach towards problem-solving?

Saharsh: For the first years, I would suggest to get well equipped with the language you are using, and get familiar with some of the basic elements of competitive programming like how to provide input, debug programs, etc. Learning Discrete mathematics can help a lot. After that take part in contests, try to learn from the codes that other people have written even if you get the correct answer using your approach. They might code the same thing in much shorter or cleaner way. Persistence is key here.