1 June 2011 Comments Off

QuestToSolve.Com | A nice attempt to improve problem solving skills

A nice attempt to improve problem solving skills: http://www.questtosolve.com/

“(…)In the spirit of Steven Halim’s World of Seven: Methods to Solve website, that posted the solutions to hundreds of problems for the University of Valladolid (UVa) Online Judge website, we have decided to not only tackle UVa problems in preparation of ACM ICPC competition, but also to post the answers that we find for each problem in the hope that our repository of solutions will be as great an informational resource to programmers everywhere as Steven’s was.

Who are we? Two students majoring in Computing Science from Simon Fraser University in British Columbia, Canada.(…)”

29 August 2010 Comments Off

Getting Started in UVa Online Judge

Getting Started in UVa Online Judge

by Zac Friggstad

The UVa Online Judge is a web site where you can try solving a number of algorithmic problems by implementing the solution in C, C++, Pascal or Java. The problems are usually described in a few paragraphs and some sample input and output is given for the purpose of illustration. For example, the problem might state that a weighted, undirected graph is given as input and you are to output the cost of the minimum spanning tree.

Solving a problem on the UVa Online Judge requires the following:

  • Read and understand the problem statement
  • Devise an algorithm to solve the problem
  • Implement the algorithm in C, C++, Pascal or Java
  • Finally, if you are convinced of its correctness, upload your code to have it judged.

The judging is automated (they use benchmark input and output files), so you can typically expect a response within a few seconds.

Getting Started: A Step-By-Step Introduction

The website is located at http://uva.onlinejudge.org/. After registering, choose the “browse problems” link on the lower-left side of the main page. From here, you will be asked to choose which problem set volume you want to browse.

Since this is a tutorial, I will suggest a problem. Follow the “Contest Volumes” link and select “Volume CXI” from here. We are going to try problem number “11172: Relational Operator”, so select it from the list.

Begin by reading the problem statement; hopefully you realize that the problem is absolutely trivial. Don’t worry, there are plenty of far more interesting problems on the archive. This problem is chosen to help you get used to the mechanics of the judge.

Make sure you are comfortable with the input and output specifications. When you submit the problem, the judge will supply their own input based on the input specification and the judge expects the output to conform to the specification in the problem description.

Begin by coding the problem. You should read the input from standard input and write to standard output (e.g. cin and cout in C++ or scanf() and printf() in C). For example, the following C++ code would solve this problem:

#include <iostream>
using namespace std;
int main() {
int n, a, b;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a >> b;
if (a < b) cout << '<' << endl;
else if (a > b) cout << '>' << endl;
else cout << '=' << endl;
return 0;

Try compiling this problem and testing it with the sample data; I suggest creating a file with the sample input and supplying this file to the program as standard input. For example, if the program name is ‘relational’ and the file name is ‘input.dat’, then you can test your code by executing ./relational < input.dat from a terminal window.

Does it work? Great! You are ready to try submitting it to the judge. In the upper-right corner of the problem description page you should see the graphic . Clicking on this will bring you to the submission page for this problem. Select the language you coded the problem in and upload the file using the upload tool. Once you are ready, click submit and hope for the best!

You can check the status of your submission by selecting the “My Submissions” link on the left side of the page. The “Verdict” heading will tell you if it was solved or if there was a problem (e.g. wrong answer, ran too long, crashed, too much memory was used, compile error, etc).

Now go ahead and solve some more problems!


27 August 2010 2 Comments

How to get started with TopCoder?

How to get started with TopCoder?

by  Vaibhav Pandey

After successfully coding the first time in Topcoder, I really feel greatful in sharing my experience with all. Simply, it was great. Got to learn a lot of new things. I have started it too late but being in UPTU and that too in a college where seniors are not that into coding, it was still very early.. ;)

So, I am writing this post to acquaint my mates with the TopCoder Competitions. What I m goin to discuss is all about the algorithm competitions.
Top Coder is a programming arena where you are given a set of problems and you have to solve them (in your preferred language) in a given amount of time. There are some simple steps to follow before starting with the coding competition:

  • Goto Topcoder site and get yourself registered.
  • Now when you are registered, download the Topcoder arena. You will need Java to be installed in your system for making the applet run.
  • Get yourself an editor(I use KawigiEdit). The editor helps in generating the code required for the competition. If you need help to install it.. read this.
  • Start the contest application and start navigating. There are practice rooms where you can practice the earlier SRM’s(single round matches).

SRM are the single round matches which are organized twice every month. You are given three problems to solve. What you need to do is to generate the code using KawigiEdit and simply put your logic in the function provided.
The important point about TopCoder is that you don’t use the main() method in your code. All your logic is dumped inside a function and you have to return your answer instead of printing it.
The several phases of the competition are:

  • Coding Phase: During this phase you are given 75mins of time to solve as many problems as you can. What you need to do is to write your code, compile it and after rigourous testing on test cases provided and some of your own test cases, “submit” it.
  • Intermission: 5mins intermission.. I hear a song usually.. :)
  • Challenge Phase: During this phase in 20mins time any of the room members can see your code or you can see theirs. If anyone finds anything wrong with anyone’s code, he can simply challenge it. If he succeeds the submitted problem will be discarded and points will fall back to 0.00
  • System Testing Phase: After the challenge phase comes System Testing Phase. This takes a fare bit of time. After near about 20mins you can goto tools and room summary for checking whether your code passed the System Testing or not.


26 August 2010 2 Comments

ACM-ICPC How to get started?

by Chua Hock-Chuan (ehchua@ntu.edu.sg)

To know more about ICPC, read the ICPC mother site (@ http://icpc.baylor.edu/icpc/) or Wiki “ICPC”. To summarize, ICPC is the programming contest for the university students (just like the IOI – International Olympiad in Informatics – is the programming contest for high school students). The ICPC contest rules are:

  • Each team consists of THREE students
  • Each team is given only ONE computer
  • Each team is given 5 hours to solve 8-10 problems (in C, C++, Java and possibly Pascal)
  • The team who solves the most number of questions in the shortest time is the winner
  • There are two stages for the contest: Regional’s and the Grand Final. Winners of each regional contest proceed to the Grand Final


Step 0.1 – Read, Read, Read: on programming, data structures, algorithms, and object-oriented programming.

Step 0.2 – Pick your Language: Pick a programming language that you are comfortable, either C++ or Java or both (but not C nor Pascal as they lack advanced libraries).

Step 0.3 – Gather Programming Resources: Gather programming books and materials, especially online references and resources.

Step 0.4 – Setup your Programming Workbench: If you can afford a laptop, get one (so that you can program at the Starbucks and in the train).

Depending on the host, the contest could be run on Linux (most likely) or Windows or any other exotic machines.

For Java programmers
Use JDK 1.5 and above, which greatly simplifies the IO processing. The Java IDE of choice is certainly eclipse – an open-source IDE supported by IBM (the official sponsor of the contest), and it runs on both Linux and Windows. For newcomers, read “How to install Eclipse“, “writing your first Java program in Eclipse“, and “debugging Java program in Eclipse“.

For C/C++ programmers
It is harder to decide because you have a few options:

Important for All Programmers

  • You should be familiar with the use of graphical debugger to improve your programming efficiency and productivity.
  • You should be familiar with the libraries, such as Java’s API and C++ STL.
  • [TODO] more

Step 0.5 – Online Judges and Training Sites: There are many “online practice sites” called online judge, that archive hundreds (or even thousands) of past contest problems. You could try the problems at your own time and own target, and submit your solutions online. You program will be automatically compiled and run with a carefully-designed set of test inputs. The status of the run, such as “accepted”, “wrong answer”,”compile error”, “presentation error”, “time limit exceeded”, “memory limited exceed”, “output limit exceed” will then be shown to you. In the case of compilation error, some of the sites may also show you the compilation error messages.

These are the sites that I frequently used (google or wiki “icpc”, “online judge” to get the full list).

  • Peking University Online Judge (PKU): This site support many languages, including Java (JDK 1.5), GNU’s GCC/G++ (for C/C++) and Visual C/C++ version 6.
  • Universidad de Valladolid Online Judge (UVA): This is the most reputable site, with a good forum (equipped with search). The support for C++ is excellent, however, the support for Java is mediocre (no JDK 1.5).
  • USA Computing Olympiad (USACO) Training Program: This is the training site for IOI (International Olympiad in Informatics for high school students) instead of ICPC. However, it provides a very systematic training on the algorithms frequently encountered in contests, e.g., shortest path, greedy, dynamic programming, heuristic search, minimum spanning tree, and etc. It supports C, C++ and JDK 1.5.


5 July 2010 Comments Off

CUHK Summer Training 2010

CUHK Summer Training 2010

CUHK is one of the best programming campus around the world. they are forming a training session below. Their success so far:

In ACM ICPC World Finals

Details of the training: http://appsrv.cse.cuhk.edu.hk/~acmprog/web2008/training2010.php