Archive | Online Judge RSS feed for this section

13 January 2011 Comments Off

Easy ACM UVa problems

Problem No Problem Name
100 The 3n+1 problem
102 Ecological bin packing
113 Power of cryptography
136 Ugly numbers
190 Circle through three points
264 Count on Cantor
272 TEX qoutes
299 Train swapping
305 Joseph
353 Pesky Palindromes
369 Combinations
382 Perfection
401 Palindromes
406 Prime cuts
408 Uniform generator
424 Integer inquery
444 Encoder and decoder
458 The decoder
490 Rotating sequences
492 Pig latin
495 Fibonacci freeze
499 What’s the frequency, Kenneth?
530 Binomial showdown
541 Error correction
543 Goldbach’s conjecture
579 Clock Hands
591 Box of Bricks
609 DNA sorting
623 500!
686 Goldbach’s conjecture (II)
694 The Collatz sequence
713 Adding reversed numbers
729 The Hamming distance problem
834 Continued Fractions
10008 What’s Cryptanalysis?
10013 Super long sums
10018 Reverse and Add
10019 Funny Encryption Method
10035 Primary Arithmetic
10055 Hashmat the brave warrior
10062 Tell me the frequencies!
10070 Leap Year or Not Leap Year
10082 WERTYU
10101 Bangla numbers
10107 What is the median?
10110 Light more light
10161 Ant on a Chessboard
10200 Prime time
10235 Simply Emirp
10242 Fourth point!!
10252 Common Permutation
10282 Babel fish
10286 Trouble with a pentagon
10300 Ecological Premium
10302 Summation of Polynomials
10323 Factorial! You Must be Kidding!!!
10324 Zeros and Ones
10327 Flip sort
10370 Above average
10409 Die game
10420 List of conquests
10424 Love calculator
10432 Polygon inside a circle
10473 Simple base conversion
10515 Powers et al.
10611 The playboy chimp
10696 f91
10700 Camel trading
Tags: , , ,
29 August 2010 Comments Off

10487 – Closest Sum

#include <stdio.h>
int main()
int n, i, q, c, sz, idx, idx2, t1, t2, elteres, ce = 0;
if(!n) break;
printf("Case %d:\n",++ce);
int set[n], i = 0, q = 0;
sz = n;

elteres = 2147483647;
for(idx = 0; idx < sz; idx++)
for(idx2 = idx + 1; idx2 < sz; idx2++)
if(  abs((set[idx] + set[idx2]) - c) < elteres  )
elteres = abs((set[idx] + set[idx2]) - c);
t1 = set[idx];
t2 = set[idx2];
printf("Closest sum to %d is %d.\n",c,t1+t2);
return 0;
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 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!


17 August 2010 Comments Off

Why programming competition contestants use C++ and Java?

Why programming competition contestants use C++ and Java?

Great question! As someone who has dabbled in programming contests a bit myself, I may have something to say.

[Let's get the standard disclaimer out of the way: contest programming is only loosely related to "programming in the real world", and while it tests algorithmic and problem-solving skills and the ability to come up with fast bug-free working code under time pressure, it does not necessarily correlate with being able to build large software projects, write maintainable code, etc (beyond the fact that well-structured programs are easier to debug).]

Now for some answers:

* C++/Java are more common than other languages in the real world as well, so you’d expect to see a higher proportion anywhere. (But it’s even higher in the contest population.)
* Many of these participants are students, or got into contests as students, and C++/Java are more common “first languages” that students learn. (Undergrad students these days may start with Scheme, Haskell, Python, etc., but high-schoolers (often self-taught) less often.) In fact, many of the Eastern European participants still use Pascal, and are more amazing with it than the rest of us will ever be with any language. [...]

16 August 2010 Comments Off

DOMjudge (alternative to PC^2) – an Automated Judge System

DOMjudge is an automated judge system to run programming contests. It has a mechanism to submit problem solutions, have them judged fully automatically and provides (web)interfaces for teams, the jury and the general public.

DOMjudge is meant to be used in programming contests like the ACM ICPC programming contests, where teams are on-site and there is a fixed problem set and timeframe. It is not meant for on-line submission systems like the UVa online judge or as courseware, although other people have modified it to that end.

Key aspects include:

  • Lightweight, depends on standard software to do its task
  • Webinterface for portability and simplicity
  • Scalable: distributed judging is easy
  • Modular system for plugging in languages/compilers
  • Features rejudging, clarifications, detailed submission/judging info
  • Designed with security in mind
  • Compatible with ICPC Validator Standard
  • It’s Open Source, Free Software

It has been used in many live contests, including:

There is also the online demo to see a live DOMjudge setup (with some non-working details).


This is a (rough) list of the requirements for DOMjudge.

  • At least one machine running Linux, with local root access
  • Apache web server with PHP 5 and PHP command line interface
  • MySQL database server version 4.1 or newer
  • Compilers for the languages you want to support

For a complete list please refer to the administrator manual.


The latest stable release is 3.1.0, dated 14 July 2010.

download here


13 August 2010 Comments Off

Contests List by David Bolton

Contests List by David Bolton

There are many more contests than we have listed here. Most important of all you can use C, C++ or C# in these.

Annual Contests

* International Conference on Functional Programming (ICFP). This has been running for a decade and happens in June or July each year. Though it’s based in Germany, anyone can enter using any programming language, from any location. It’s free to enter and your team isn’t limited by size. In 2010 it’s from June 18-21

* The BME International is an intense free to enter contest that takes place in Europe once a year for teams of three, and you have to bring your own computers and software. This year, the 7th took place in Budapest. This has had some interesting challenges in the past- how about driving a car over a virtual terrain? Other past tasks included controlling an oil-company, driving an assembly line robot and programming for secret communication. All programs were written in one 24 hour intense period!

* International Collegiate Programming Contest. One of the longest running- this started in 1970 at Texas A&M and has been run by the ACM since 1989 and has IBM’s involvement since 1997. One of the bigger contests it has thousands of teams from universities and colleges competing locally, regionally and ultimately in the a world final. The contest pits teams of three university students against eight or more complex, real-world problems, with a gruelling five-hour deadline.

* The Obfuscated C contest has been running for nearly 20 years. This is done on the internet, with email submissions. All you have to do is write the most obscure or obfuscated Ansi C program in under 4096 characters length according to the rules. The 19th contest took place back in January/February 2007.

* The Loebner Prize is not a general programming contest but an AI challenge to enter a computer program that can do the Turing test, ie talk to a human sufficiently well to make the judges believe they are talking to a human. The Judge program, written in Perl will ask questions like “What time is it?”, or “What is a hammer?” as well as comparisons and memory. The prize for the best entrant is $2,000 and a Gold Medal.

* Similar to the Loebner Prize is the Chatterbox Challenge. This is to write the best chatter bot- a web based (or downloadable) application written in any language that can carry on text conversations. If it has an animated display that syncs with text then that is even better- you get more points!