Some Good Tips I Learned in SRM 543
I finished SRM 543 with only 170++ points, solving only the 250-pointer. Actually, I did solve the 500-pointer, but I forgot to erase a huge unused array that made my program used ~ 70 MB and thus failed due to memory limit. That was my second time failing a Medium for a stupid MLE bug. The first time was when I forgot to decrease the first dimension of a 2D DP array from N to 2 after I decided to “flying table” optimization.
As usual, after the match was over, I had some chats with other coders in the Arena. This time I discussed with vexorian and writer (which happened to be espr1t) about how to avoid such stupid bug. Here is a list of tips I learned from them.
- If you use an external editor to code your solution, make sure you test your solution for the largest case in the Arena before submitting. This is to make sure that your solution don’t get TLE/MLE in the largest case.
- To quickly enter the largest case in the Arena’s test feature, create a program that can generate and output that quickly. For example, a program that generates array of 50 random integers, array 50 “1,000,000,000″s, array of random strings, etc. in TopCoder’s input format, like “{100, 100, 100, …, 100}”.
- Don’t read the example cases when you are solving a problem. Only read them if the statement is too confusing or you fail some of the examples when running your completed solution.
- TopCoder’s C++ compiler uses -O2 compiler optimization. You should also turn on that option when testing your solution in external editor.
I think I’m going to follow those pieces of advice and see if they improve my performance.
How I Became a TopCoder SRM Problem Writer
I have been writing SRM problems quite often in past months. It has been a very exciting experience for me. I would like to recall how I became a problem writer in this competition…
Member SRM 489
… so I would like to suggest you to write Div-2 part of Member SRM 489. If you agree, …
Thanks,
Ivan
That was my first approval statement from mystic_tc (Ivan) for writing an SRM. Yay! I received that email after I proposed a problemset for a Member SRM. Ivan posted a “Looking for Member SRM 489 writers” thread in the forum, then I tried to propose, and I was glad that the proposal was approved. I was really really happy that time.
For those who don’t know, Member SRM is actually a regular SRM whose writers and testers are not paid. It is voluntary for keeping 3 SRM per month. That was OK for me as what I want was the experience of working together with the admins to prepare an SRM.
I actually proposed a complete set of five problems, but it turned out that the Div-1 problems did not satisfy Ivan. Yes, when I read the problems now, I realized that they are very lame problems. Therefore, Ivan assigned me to write only the Div-2 part. The Div-1 problems were written by rng_58. read more
Introducing Contest Toolkit Page
I’m introducing you a new page in this blog: Contest Toolkit. You can access it by clicking the last link in the menu bar.
There are two main features of this toolkit.
Contest Problems
Past programming contest problems, such as IOIs, are often only available in PDFs — you may be too lazy to download the PDF files just to read the problems. In this section I’m planning to collect many past contest problems and transform them into more user-friendly HTML version. I’ll also try to include the solutions to all problems in their respective problem page. Furthermore, you can discuss the problems in the comment section!
The main goal of this section is to collect all problems of high school programming contests such as IOI, CEOI, and regional contests such as APIO.
Contest Materials
This section will consist of many useful links that I think are important for coders to read. From a list of online judges, tutorials, interesting blogs, and many more.
The main goal of this section is to provide a one-stop resource of all useful links for programming contest.
==
Note that this page is still in heavy construction. Your feedback or suggestion are welcome!
CodeSprint 2 Interview Street Problems Analysis
I participated in the second CodeSprint that was held in January 7 – 8 2012. I knew this contest from a link posted in a TopCoder forum thread. As far as I know, many companies will use the result of this contest to interview new employees/interns. Because I was in holiday after the final exams, I took part in this contest, maybe somehow by luck I could get interview from some companies
The contest had three types of problems: algorithmic, company, and real-world problems. The algorithmic ones are much like usual competitive programming problems. Company problems are set by some of the companies. Real-world problems are “real”, for example, one of them is creating a web service for resizing company logos.
During the 48-hour contest (yes, only 2 days), I managed to solve 6 algorithmic problems and 1 company problem. I ranked #38 overall and #2 in Indonesia (the first rank went to dolphinigle).
Here is an analysis on some of the problems. read more
ACM-ICPC Asia Manila Regional Contest 2011
Well, this is my third participation in an ICPC regional. This time we as Saklar Lhompat team participated in Philippines, in Manila site. This is also my second time to participate in a foreign site, as (unfortunately) Jakarta didn’t host a regional this year. University of Indonesia had also sent two other teams (Vidina and Algorythmists) to Kuala Lumpur site this year.
Honestly, we expected to become a world finalist this year
. We had participated in nearly all college national programming contests before, and got pretty nice results. Each of us also practiced regularly in online judges, me especially in TopCoder (SRMs). So, we hoped that we got some luck and succeeded this year.
Preparation
We were assigned a new coach, Denny. He participated in an ICPC regional in around 2000′s. My teammates were also the same as the previous year, i.e., Alham Fikri Aji and Berty Tobing.
The teams were selected by choosing the top 3 teams from my university in Indonesia National Contest. Then, our team was selected to participate in Manila, while the two other teams were selected to compete in Kuala Lumpur.
I told Ilham Kurnia, my programming contest trainer, that we were going to take the Manila regional. He immediately warned me that from his previous experience in competing in Manila twice, this site was always badly organized. The problem statements were ambiguous, the clarification was not so helpful, etc. So, he advised us to anticipate for every bad things that might happen during the contest. read more
Wanna Play My Diglett Hunter Game?
This is my third semester in Faculty of Computer Science, University of Indonesia. We got an interesting assignment from Web Design and Programming class: to create a “catching mouse” game. The game must be created as a plain HTML file with Javascript and must make use of browser cookies. The deadline was about two weeks.
So, here is my submission: Diglett Hunter. It has poor design; but well, at least the game works. You can choose on of the three themes for the interface. When you make a new high score, your score will be recorded (in browser cookies, not in server
).
Here is a quick explanation on several parts of the game. Note that this explanation is not exhaustive. It is assumed that you know the basics of HTML DOM and Javascript.
Generating Board
The board consists of 5 x 5 unit squares, generated by the following JS code. This is actually a <table> that consists of 5 <tr>s, each consisting of 5 <td>s.
function genBoard()
{
document.write('<table id="tableBoard">\n');
for (var i = 0; i < 5; i++)
{
document.write('<tr>\n');
for (var j = 0; j < 5; j++)
{
document.write('<td id="tdCell' + i + j + ');">');
document.write('<a href="#"><img id="imgCell' + i + j + '" src="mouse.png" onclick="hitCell(' + i + ', ' + j + ');"/></a>');
document.write('</td>');
}
document.write('</tr>\n');
}
document.write('</table>\n');
}
Each cell has onlick attribute that specifies what to do if the user clicks on that cell. Please consult to scripts.js for more reference
read more
TopCoder SRM 524: Cool Problemset
After sadly missing several past SRMs, finally I participated in another SRM round again. This time the problemset was written by a first-time writer, cgy4ever. In my opinion, the problemset was nice and ideal. I enjoyed the match.
Here is my favorite problem.
D1-250. MagicDiamonds (Passed System Test, 147.56)
I like this problem very much. The problem looks very easy yet it contains a dangerous pitfall.
Abridged problem statement: You want to transfer n (1 <= n <= 10^12) Magic Diamonds using Transfer Magic. In one usage of Transfer Magic, you can transfer any number of Magic Diamonds, as long as the number is not prime. What is the least amount of Transfer Magic usages required?
The problem statement looks very simple. The example cases imply a very simple solution, too: if n is not prime, the answer is 1, else the answer is 2. Thus, in the first minutes of the match, many coders submitted solutions to this problem with very high scores, around 248++.
During the match, I came up with the same logic, too.
- If n is not prime, then as the problem statement says, you can use only one Transfer Magic.
- Else n is prime. First, use one Transfer Magic. Then, (n-1) won’t be prime, so you can use another final Transfer Magic.
Checking for primality of n can be done in O(sqrt(n)) very easily: loop for all integers 2 <= x <= sqrt(n), and check whether x divides n. So, I coded my solution fast, and submitted for 246++ points. The examples contain several boundary cases (n = 1 and n = 2), so I felt safe to submit the solution. read more
Programmer’s Gags
Here is a collection of funny programmer’s jokes of my choice, from all around the web. Have fun!
Random Number

fushar





