However, you can get all the advices & guidelines by surfing for hours

But why not get them in minute?

Collected by - Ahmed Shamsul Arefin


 

University of Valladolid online judge

 

 

 

Ehem...some categories seem incorrect, and some problems cannot be classified into any categories and some problems can be classified into many categories...

Problem Category

Problem Numbers:

Ad Hoc (if I don't know which category the problem is, I simply put it here)

101,102,105,107,118,119,120,121,128,139,142,145,
154,155,187,195,227,232,271,272,291,299,300,311,
320,325,327,330,333,340,344,349,380,384,394,401,
408,409,413,414,417,434,441,442,444,447,455,457,
460,466,482,483,484,489,492,494,496,499,537,541,
542,562,573,574,576,579,580,587,591,612,616,617,
621,642,654,661,668,671,673,729,755,10018,10038,
10055,10079,10098,10107,10015,10070,10126

Mathematic

113,138,160,202,256,264,275,276,294,326,343,347,
350,356,369,374,382,386,412,465,471,474,485,495,
498,530,557,575,594,713,725,727,2182,10006,10008,10013,10019,10035,10071,10093,10125,10110

Graph Problems/Tree

112,117,122,336,352,383,422,429,459,469,532,536,
567,572,590,614,615,657,677,762,785,10000,10004,
10009,10010,10016

Simulation

130,133,144,151,305,339,379,402,440,637,758

Dynamic Programming

108,116,136,147,231,357,640,674,10003,10074

Output-Related

312,337,381,391,392,400,403,445,488,706

Computational Geometry

190,191,438,476,477,478,10012

Prime Numbers

406,516,543,583,686

Big Numbers

324,424,568,623,748

Chess

167,278,439,750

Encryption

458,740,10008,10062

Base Numbers

343,355,389,446

Anagrams

156,195,454,630

3n+1

100,371,694

Card Game

555

 

 

My Unsolved Problems

There are still many problems that I always get Wrong Answer... If someone who see this website has got these problems accepted, please tell me your algorithm (please...), thanks :-)

No

Problem Name

Problem

104

Arbitrage

possibly precision error

107

The Cat in the Hat

they re-judge the problem

125

Numbering Paths

don't know where is the error

139

Telephone Tangles

they re-judge the problem, what did they change?

143

Orchard Trees

wrong algorithm

195

Anagram

they re-judge the problem, what did they change?

253

Cube Painting

I use brute force... but does not work

306

Cipher

Time Limit Exceeded

338

Long Multiplication

what's wrong with this?????????

378

Intersecting Lines

possibly precision error

385

DNA Translation

I have problem with C function strrev, help...

397

Equation Elation

I don't know where is the mistake

416

LED Test

don't understand this problem

468

Key To Success

????

485

Pascal's Triangle of Death

VERY BIG NUMBER???

531

Compromise

dunno

545

Heads

This one similar to 474, why WA?

601

The Path

confused

604

The Boggle Game

dunno

620

Cellular Structure

Unknown Error

679

Dropping Balls

Runtime Error 11 (SigSegv)

701

The Archeologist Dilemma

Need test case

710

The Game

Runtime Error 11 (SigSegv)

726

Decode

WA

739

Soundex Indexing

What's wrong with this?

763

Fibinary Numbers

What's wrong with this?

782

Contour Painting

What's wrong with this?

10036

Divisibility

WA

*

Many Others...

Still in process of finding good algorithms...

 

 

ACM International Collegiate
Programming Contest 2000

by Lynellen D. S. Perry

ACM Crossroads interviewed Susan Puglia, Executive Sponsor of the 2000 ACM International Collegiate Programming Contest. Puglia is the Vice President for Server Development and the Director of the Toronto Laboratory of the IBM Software Group.

Crossroads: How did you arrive at your present job?
Puglia: My undergraduate degree was in math and computer science. Directly out of collage I joined IBM as a programmer, I've been with IBM for 19 years and I'm now in engineering lab management.

Crossroads: What has it been like to be a technical woman at IBM?
Puglia: Mentors have been key to steering my direction. As the industry has grown, demand for technical staff far outstrips supply. Thus, one can move around to get experience in a variety of fields. IBM has a low attrition rate partly do to the size of the company, which means that there is lots of opportunity and variety internal to IBM.

Crossroads: In what ways does IBM encourage women staff members?
Puglia: IBM has corporate and regional networking for women, formal mentoring inside IBM with a focus in career development, and IBM takes time to think about how to recruit women to IBM and to information technology in general. IBM also is reaching out to the next generation of technical staff by starting programs for pre-collage students. For example, IBM in Canada has an annual one-day event to interest 7th and 8th grade girls in computing technology.

Crossroads: What are your problem solving techniques?
Puglia: When I encounter a problem that is outside my sphere of knowledge, I find an appropriate expert in the technology and also an expert with a business view of the situation if possible.

Crossroads: How do you get yourself to think creatively?
Puglia: I take a break and return later, or try to look at the problem from a different angle, or talk to someone else about the problem or idea.

Crossroads: How does the ACM programming contest encourage women to study computer science?
Puglia: The ACM programming contest is prestigious. When women compete in this contest, they show students that females can be successful in computer science. In 1999, 471 of the 13,000 participants at the regional contest level were women.

Crossroads: What further steps can encourage women to enter computing?
Puglia: Role models and mentors are very important, especially early. It is interesting to note that 45% of all jobs in America are filled by women but only 4% of the IT jobs are held by women.

Crossroads would like to congratulate all participants in this year's programming contest, and especially the following winners: From St. Petersburg State University, Nikolai Durov, Andrei Lopatine, Oleg Eterevsky, reserve Victor Petrov, and coach Natalia N. Voyakovskaya. For details about the 2000 World Finals or information about how to compete in this year's Regional Finals, see acm.baylor.edu/acmicpc.

Crossroads highly encourages you to consider entering the ACM International Collegiate Programming Contest. For tips and strategies, see our award-winning key resource article called Teamwork in Programming Contests: 3 * 1 = 4.

Last Modified: Sunday, 21-Jan-01 17:06:25
Location: www.acm.org/crossroads/xrds6-5/progcon.html

© Copyright 2000-2001 by ACM, Inc.

 

Common Mistakes in Online and Real-time Contests

by Shahriar Manzoor

Introduction

Each year the Association for Computing Machinery (ACM) arranges a worldwide programming contest. This contest has two rounds: the regional contests and the World Final. The teams with the best results in the regional contests advance to the World Final. The contest showcases the best programmers in the world to representatives of large companies who are looking for talent. When practicing for programming competitions, remember that all your efforts should be directed at improving your programming skills. No matter what your performance is in a contest, don't be disappointed. Success in programming contests is affected by factors other than skill, most importantly, adrenaline, luck, and the problem set of the contest. One way of getting immediate feedback on your efforts is to join the Valladolid Online Programming Practice/Contest or the online judge hosted by Ural State University (USU). Successfully solving problems increases your online ranking in the respective competitions.

This article is for beginning programmers who are new to programming contests. I will discuss the common problems faced in contests, the University of Valladolid online judge, and the USU online judge. The suggestions are divided into three parts: General Suggestions, Online Contest Suggestions, and Valladolid-Specific Suggestions. Throughout this paper, please note that in real-time contests, the judges are human and in online contests, the judges are computer programs, unless otherwise noted.

Different Types of Programming Contests

Many programming contests take place throughout the year, such as ACM regional contests, International Olympiad in Informatics (IOI), Centrinës Europos informatikos olimpiados (CEOI), and Programmer of the Month (POTM) contest. The most prestigious live programming contest is the ACM International Collegiate Programming Contest (ICPC), and the most prestigious online contest is the Internet Problem Solving Contest (IPSC). In this section, I will discuss some of the contests.

ACM International Collegiate Programming Contest (ICPC)

ICPC, first held in 1977, is now held yearly [4]. The contest lasts five hours and generally contains eight problems. (However, the 2001 World Finals contained nine problems.) Three person teams are allotted a single computer. The teams submit their solutions to a judging software named PC2 developed at California State University, Sacramento (CSUS). The permitted programming languages are C/C++, Pascal, and Java.

Online Contests

Online contests require no travel and are often less tense [1]. The submission rules for the online contests at the Valladolid site and the USU online judge site are the same: the contestants must mail their solutions to a certain e-mail address. The IPSC rules are quite different. The IPSC Contest Organizer provides inputs for the problems. Instead of e-mailing their solutions, the contestants have to e-mail their outputs.

Some Tips for Contestants

A good team is essential to succeeding in a programming contest. A good programming team must have knowledge of standard algorithms and the ability to find an appropriate algorithm for every problem in the set. Furthermore, teams should be able to code algorithms into a working program and work well together.

The problems presented in programming contests often fall into one of five categories including search, graph theoretic, geometric, dynamic programming, trivial, and non-standard. Search problems usually require implementing breadth-first search or depth-first search. Graph theoretic problems commonly include shortest path, maximum flow, minimum spanning tree, etc. Geometric problems are based on general and computational geometry. Dynamic programming problems are to be solved with tabular methods. Trivial problems include easy problems or problems that can be solved without much knowledge of algorithms, such as prime number related problems. Non-standard problems are those that do not fall into any of these classes, such as simulated annealing, mathematically plotting n-queens, or even problems based on research papers. To learn more about how problems are set in a contest you can read Tom Verhoeff's paper [6].

What you should do to become a good team

There is no magic recipe to becoming a good team, however, by observing the points below (some of which were taken from Ernst et al. [3]) you can certainly improve. When training, make sure that every member of the team is proficient in the basics, such as writing procedures, debugging, and compiling. An effective team will have members with specialties so the team as a whole has expertise in search, graph traversal, dynamic programming, and mathematics. All team members should know each other's strengths and weaknesses and communicate effectively with each other. This is important, for deciding which member should solve each problem. Always think about the welfare of the team. Solving problems together can also be helpful. This strategy works when the problem set is hard. This strategy is also good for teams whose aim is to solve one problem very well. On the other hand, the most efficient way to write a program is to write it alone, avoiding extraneous communication and the confusion caused by different programming styles.

As in all competitions, training under circumstances similar to contests is helpful. During the contest make sure you read all the problems and categorize them into easy, medium and hard. Tackling the easiest problems first is usually a good idea. If possible try to view the current standings and find out which problem is being solved the most. If that problem has not yet been solved by your team, try to solve it immediately, odds are it is an easy problem to solve. Furthermore, if the your solution to the easiest problem in the contest is rejected for careless mistakes, it is often a good idea to have another member redo the problem. When the judges reject your solution, try to think about your mistakes before trying to debug. Real-time debugging is the ultimate sin, you don't waste too much of your time with a single problem. In a five-hour contest you have 15 person-hours and five computer-hours. Thus, computer-hours are extremely valuable. Try not to let the computer sit idle. One way to keep the computer active is to use the chair in front of the computer only for typing and not for thinking. You can also save computer time by writing your program on paper, analyzing it, and then use the computer. Lastly, it is important to remember that the scoring system of a contest is digital. You do not get any points for a 99%-solved problem. At the end of the contest you may find that you have solved all the problems 90%, and your team is at the bottom of the rank list.

Different Types of Judge Responses

The following are the different types of judge replies that you can encounter in a contest [2]:

Correct

Your program must read input from a file or standard input according to the specification of the contest question. Judges will test your program with their secret input. If your program's output matches the judges' output you will be judged correct.

Incorrect output

If the output of your program does not match what the judges expect, you will get an incorrect output notification. Generally, incorrect output occurs because you have either misunderstood the problem, missed a trick in the question, didn't check the extreme conditions or simply are not experienced enough to solve the problem. Problems often contain tricks that are missed by not reading the problem statement very carefully.

No output

Your program does not produce an output. Generally this occurs because of a misinterpretation of the input format, or file. For example, there might be a mixup in the input filename e.g., the judge is giving input from "a.in," but your program is reading input from "b.in." It is also possible that the path specified in your program for the input file is incorrect. The input file is in most cases in the current directory. Errors often occurs because of poor variable type selection or because a runtime error has occurred, but the judge failed to detect it.

Presentation error

Presentation error's occur when your program produces correct output for the judges' secret data but does not produce it in the correct format. Presentation error is discussed in detail later in this article.

Runtime error

This error indicates that your program performs an illegal operation when run on judges' input. Some illegal operations include invalid memory references such as accessing outside an array boundary. There are also a number of common mathematical errors such as divide by zero error, overflow or domain error.

Time limit exceeded

In a contest, the judge has a specified time limit for every problem. When your program does not terminate in that specified time limit you get this error. It is possible that you are using an inefficient algorithm, e.g., trying to find the factorial of a large number recursively, or perhaps that you have a bug in your program producing an infinite loop. One common error is for your program to wait for input from the standard input device when the judge is expecting you to take input from files. A related error comes from assuming wrong input data format, e.g., you assume that input will be terminated with a "#" symbol while the judge input terminates with end-of-file.

General Suggestions for Contests

Maximum memory

The maximum memory allowed on the Valladolid site is 32MB. This includes memory for global variables, the heap, and the stack. Even if you find that you have allocated much less than 64K memory, you will find that the judge often shows that more memory has been allocated. Also, you should not allocate 32 MB of global memory because 32MB is maximum for all types of memory. The maximum memory for real contests varies; for the World Final, it is greater than 128MB.

Problems with DOS Compilers and memory allocation

Many of us like to use DOS compilers like Turbo C++ 3.0 and Borland C++, which do not support allocating more than 64K memory at a time. It is always a good idea to allocate memory with a constant so that your test runs use less than 64K memory. Before the submit run, the size of memory can be increased by just changing the value of the constant. If you don't practice this, it is very likely that you will face problems like "Run time error," "Time limit exceeded," and "Wrong answer." An example:

int const SIZE=100;
       int store[SIZE][SIZE];
       void initialize(void)
       {
           int i,j;
    for(i=0;i<SIZE;i++)
               for(j=0;j<SIZE;j++)
                   store[i][j]=0;
       }

"Time limit exceeded" is not always "Time limit exceeded"

When you submit a program to the judge, the judge gives you a response, but this response is not always accurate. For example, if you allocate less memory than is required, the program may not terminate (it may not even crash), and the judge will tell you "Time limit exceeded." On seeing this message, if you try to optimize your program rather than correcting the memory allocation problem, your program will never be accepted. The following example illustrates this problem. The skeleton of your program is as follows:

#include <stdio.h>
       int const MAX=100;
       int array[MAX],I;
       void main(void)
       {
           for(i=0; i<=100;i++)
           {
               if(array[i]==100)
               {
                   array[i]= -10000;
                   - - - - - -
                   - - - - - -
                   - - - - - -
               }
           } 
       }

In this example, you have allocated a 100 element array. Your program attempts to access array element 100, which is out of the range [0..99], because of an error in the for loop statement. It will instead access the address of counter variable i. Because the value array[100] is set to 10000, the counter value will be set to 10000, so your loop will take a much longer time to terminate and may not even complete at all. So, the judge will give you message "Time limit exceeded" even though it actually is a memory allocation error.

Test the program with multiple datasets

There is always a sample input and output provided with each contest question. Inexperienced contestants get excited when one of their programs matches the sample output for the corresponding input, and they think that the problem has been solved. So they submit the problem for judgment without further testing and, in many cases, find they have the wrong answer. Testing only one set of data does not check if the variables of the program are properly initialized because by default all global variables have the value zero (integers = 0, chars = '\x0', floats= 0.0 and pointers = NULL). Even if you use multiple datasets the error may remain untraced if the input datasets are all the same size, in some cases descending in size or ascending in size. So, the size of the dataset sequence should be random. It is always a good idea to write a separate function for initialization.

Take the input of floats in arrays

Consider the following program segment:

#include<stdio.h>
float store[100];
void main(void)
{
    int j;
    for(j=0;j<100;j++)
        scanf("%f",&store[j]); 
}

When this program is run, many C/C++ compilers often show the error "Floating point format not linked." To get rid of this type of error, just change it to take the input into a normal floating point variable then assign that variable to the array, as follows:

#include <stdio.h>
float store[100];
void main(void)
{
    int j;
    float temp;
    for(j=0;j<100;j++)
    {
        scanf("%f",&temp);
        store[j]=temp;
    }
}

Mark Dettinger's suggestions on geometric problems

Mark Dettinger was the coach for the team from the University of Ulm. He suggested to me that sometimes it is a good idea to avoid geometric problems unless one has prewritten routines. The routines that can be useful are:

Judging the judge!

Judges often omit information. For example, judges in my country give the error "Time limit exceeded" but never say what the time limit is. In Valladolid, often the input size is not specified (e.g., problem 497-Strategic defense initiative).

Suppose that the maximum number of inputs is not given. This is often vital information because if the number is small, you can use backtracking, and if it is large, you have to use techniques like dynamic programming or backtracking with memorization. In problem 497, the maximum possible number of missiles to intercept is not given. Suppose that the loop

for(j=0;j<100000000;j++) 

takes one second to run for the judge, and an unknown N is the number of inputs given by the online judge. Send the following program with your code. Place it just after you have read the value of N.

for(I=1;I<=20;I++)
{
    if(I*1000>=N)
    {
        for(j=0;j<I*100000000;j++);
    }
}

From the runtime of the program you will know the number of input N. Using this method you can also determine how fast the judge's computer is compared with yours and thus find out the approximate time limit for any problem on your computer. Most of the live contests have a practice session prior to the contest. On this day you should try to determine the speed of the judge computer by sending programs consisting of many loops and nested loops.

Did you know that there was a mistake in a problem of the World Final 2000? The culprit problem was Problem F. The problem specification said that the input graph would be complete but not all inputs by the judge were complete graphs. At least one of the teams sent a program that checked if the input graph was complete. If the input graph was incomplete, then their program entered an infinite loop. So, the response from the judge was "Time limit exceeded." From this response they were able to know that some of the input graphs were incomplete and solved the problem accordingly.

Use double instead of float

It is always a good idea to use double instead of float because double gives higher precision and range. Always remember that there is also a data type called a long double. In Unix/Linux C/C++, there is also a long long integer. Sometimes it is specified in the problem statement to use float type. In those cases, use floats.

Advanced use of printf() and scanf()

Those who have forgotten the advanced use of printf() and scanf(), recall the following examples:

scanf("%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]",&line); //line is a string

This scanf() function takes only uppercase letters as input to line and any other characters other than A..Z terminates the string. Similarly the following scanf() will behave like gets():

scanf("%[^\n]",line); //line is a string

Learn the default terminating characters for scanf(). Try to read all the advanced features of scanf() and printf(). This will help you in the long run.

Using new line with scanf()

If the content of a file (input.txt) is

abc
def

and the following program is executed to take input from the file:

char input[100],ch;
void main(void)
{
    freopen("input.txt","rb",stdin);
    scanf("%s",&input);
    scanf("%c",&ch);
}

What will be the value of input and ch?

The following is a slight modification to the code:

char input[100],ch;
void main(void)
{
    freopen("input.txt","rb",stdin);
    scanf("%s\n",&input);
    scanf("%c",&ch);
}

What will be their value now? The value of ch will be '\n' for the first code and 'd' for the second code.

Memorize the value of pi

You should always try to remember the value of pi as far as possible, 3.1415926535897932384626433832795, certainly the part in italics. The judges may not give the value in the question, and if you use values like 22/7 or 3.1416 or 3.142857, then it is very likely that some of the critical judge inputs will cause you to get the wrong answer. You can also get the value of pi as a compiler-defined constant or from the following code:

Pi=2*acos(0)

Problems with equality of floating point (double or float) numbers

You cannot always check the equality of floating point numbers with the = = operator in C/C++. Logically their values may be same, but due to precision limit and rounding errors they may differ by some small amount and may be incorrectly deemed unequal by your program. So, to check the equality of two floating point numbers a and b, you may use codes like:

if(fabs(a-b)<ERROR) printf("They are equal\n");

Here, ERROR is a very small floating-point value like 1e-15. Actually, 1e-15 is the default value that the judge solution writers normally use. This value may change if the precision is specified in the problem statement.

The cunning judges

Judges always try to make easy problem statements longer to make them look harder and the difficult problem statements shorter to make them look easy. For example, a problem statement can be "Find the common area of two polygons" -- the statement is simple, but the solution is very difficult. Another example is "For a given number find two such equal numbers whose multiplication result will be equal to the given number." Though the second statement is much longer than the first, the second problem statement is only asking to find the square root of a number, which can be done using a built-in function.

Use the assert function

It is always nice to use the C/C++ assert() function, which is in the header file assert.h. With the assert() function you can check for a predefined value for a variable or an expression at a certain stage of your program. If for some reason the variable or expression does not have the specified value, assert() will print an error message. See your C/C++ documentation for further details.

Avoid recursion

It is almost always a good idea to avoid recursion in programming contests. Recursion takes more time, recursive programs crash more frequently especially in the case of parsing, and, for some people, recursion is harder to debug. But recursion should not be discounted completely, as some problems are very easy to solve recursively (DFS, backtracking), and there are some people who like to think recursively. However, it is a bad habit to solve problems recursively if they can be easily solved iteratively. In live programming contests, there is no point in writing classic code, or code that is compact but often hard to understand and debug. In programming contests, classic code serves only to illustrate the brilliance of the programmer. For example, the code for swapping two values can be written classically as:

#define swap(xxx, yyy) (xxx) ^= (yyy) ^= (xxx) ^= (yyy)

But in a contest you will not get extra points for this type of code writing.

Improve your understanding of probability and card games

Having a good understanding of probability is vital to being a good programmer. If you want to measure your grasp of probability, just solve problem 556 of Valladolid and go through a statistics book on probability. Know about probability theorems, independent and dependent events, and heads/tails probability. You should also be able to solve common card game-related problems.

Be careful about using gets() and scanf() together

You should also be careful about using gets() and scanf() in the same program. Test it with the following scenario. The code is:

scanf("%s\n",&dummy);
gets(name);

And the input file is:

ABCDEF 
bbbbbXXX

What do you get as the value of name? "XXX" or "bbbbbXXX" (Here, "b" means blank or space)

Suggestions for UNIX-based Online Judges and Contests

Function portability

Not all C/C++ functions available in DOS are available in UNIX. Check the documentation for the portability among operating systems. If a function is portable to UNIX, you can use it to solve problems on the Valladolid and USU sites. Use only standard input and output functions for taking inputs and producing outputs.

itoa(), the important function that UNIX doesn't have

UNIX does not support the important function itoa(), which converts an integer to a string. The replacement for this function can be:

char numstr[100];
int num=1200;
sprintf(numstr,"%d",num); //to decimal
sprintf(numstr,"%X",num); //to uppercase hexadecimal

Try to find replacements for other functions that are not available in UNIX/LINUX.

Problems with the settings of mailer program

Some problems don't get accepted even if they are solved correctly. Such problems from Valladolid are 371- Ackermann Function, 336-A node too far, 466-mirror, mirror, etc. It is because our e-mail programs (e.g., Outlook Express, Eudora) break longer lines, and these problems have long lines in their output. So in Outlook Express you should go to Tools-> Options-> Send-> Send text setting and change the Automatically Wrap Text from 76 (default) to 132. Similar options can be found in other mailer programs. The Ural State University online judge has a program submission form with which you can directly submit your program without sending an e-mail. Remember that problems with mailer settings can cause both wrong answers and compile errors.

Presentation error

Presentation errors are neither caused by algorithmic nor logical mistakes. There is a difference between the presentation error of online judges and that of live judges. The latter are able to detect mistakes such as misspellings, extra words, extra spaces, etc., and differentiate them from algorithmic errors, such as wrong cost, wrong decisions, etc. These mistakes are the presentation errors as graded by the human judges. On the other hand, online judges in most cases compare the judge output and the contestant output with the help of a file compare program so that even spelling mistakes can cause a "wrong answer." Generally, when the file compare program finds extra new lines, these are considered to be presentation error. Human judges, though, do not typically detect these mistakes. But now computers are becoming more powerful, larger judge inputs are being used and larger output files are being generated. In live contests, special judge programs are being used that can detect presentation errors, multiple correct solutions, etc. We are advancing towards better judging methods and better programming skills. The recent statistics of the ACM shows that participation in the ACM International Collegiate Programming Contest is increasing dramatically, and in the near future the competition in programming contests will be more intense [5]. So the improvement of the judging system is almost a necessity.

A common mistake of contestants

Recently, I arranged several contests with Rezaul Alam Chowdhury and in collaboration with the University of Valladolid and have seen contestants make careless mistakes. The most prominent mistake is taking things for granted. In a problem I specified that the inputs will be integers (as defined in mathematics) but did not specify the range of input and many contestants assumed that the range will be 0->(2^32-1). But in reality many large numbers were given as input. The maximum input file size was specified from which one could assume what was the maximum possible number. There were also some negative numbers in the input because integers can be negative.

The causes of compile error

Compile error is a common error on the Valladolid site. It may seem annoying to compile and run a program, then send it to the online judge and get a compile error. Generally these errors occur because contestants omitted #include files. Some compilers do not require including the header files even when we use functions under those header files. However, the online judge never allows this. For example, some functions exist both in math.h and stdlib.h. For the online judge, you need to include both of the header files if you want to use them. Compiler errors also occur commonly when contestants do not specify the correct language. Often C code implemented in some compilers inadvertently takes advantage of C++ features. When the language specified to the judge is C, a compile error is generated. For example, the following may be compiled as a C program in a DOS/Windows environment but not in UNIX/LINUX.

for(inti=0;i<100;i++)	
{
    printf("Compile Error\n");
}

E-mail sending format

Mail sent to the online judge should be in plain text format. If the mail is in Rich Text or HTML, the program will not compile. You should not send your program as an attachment.

Mysterious characters

When I first started programming for Valladolid, I used Turbo C++. After a program was successfully completed, I opened the source code in Notepad, selected the whole text, copied and pasted it in my mail editor, and sent the program to the Valladolid site. I got a Compile error message but could not discover the cause. One day, I pasted it in my email editor, saved it as a text file, and then opened it in my DOS text editor. I discovered some mysterious characters in the file, which were invisible in Windows. If you receive a Compile error message and cannot discover the cause, check if your mail or text editor is adding extra symbols to your code.

Using non-portable functions

Compile errors are caused by the use of the functions which are only available in DOS and not in LINUX, such as strrev(), itoa() etc.

Using C++ style comments

C++ allows a comment style that starts with //. If the mailer wraps a comment to two lines, you may get a compile error.

Valladolid-specific suggestions

The next section provides suggestions for solving problems for the Valladolid online judge.

Types of input in the Valladolid online judge

There are four types of input in the online judge. (Latest change)

What is a special correction Program?

There are some problems that have one unique output for a single input, and other problems with multiple output for the same input. For example if you are asked to find the maximum appearing string of length 3 in the string "abcabcabcijkijkijk," unfortunately the answer can be both "abc" and "ijk." So, if your program gives the output "abc," it is correct, "ijk" is also correct. The judge program cannot determine the correctness of your program by simply comparing your output to the judge program output. The judge must write a special program, which will read your answer and determine if it is right or wrong. This special program is described as a special correction program in the Valladolid online judge. For the problems with special correction programs, (Problem 104, 120, 135, etc., or the problems with orange || green flag), you cannot be sure that your program is incorrect even if your program output does not match the sample output for the given sample input.

"Multiple input programs" are an invention of the online judge. The online judge often uses the problems and data that were first presented in live contests. Many solutions to problems presented in live contests take a single set of data, give the output for it, and terminate. This does not imply that the judges will give only a single set of data. The judges actually give multiple files as input one after another and compare the corresponding output files with the judge output. However, the Valladolid online judge gives only one file as input. It inserts all the judge inputs into a single file and at the top of that file, it writes how many sets of inputs there are. This number is the same as the number of input files the contest judges used. A blank line now separates each set of data. So the structure of the input file for multiple input program becomes:

Integer N     //denoting the number of sets of input
--blank line---
input set 1 //As described in the problem statement
--blank line---
input set 2 //As described in the problem statement
--blank line---
input set 3 //As described in the problem statement
--blank line---
.
.
.
--blank line---
input set n  //As described in the problem statement
--end of file--

Note that there should be no blank after the last set of data. Sometimes there may be, so always check. The structure of the output file for a multiple input program becomes:

Output for set 1 //As described in the problem statement
--Blank line---
Output for set 2 //As described in the problem statement
--Blank line---
Output for set 3 //As described in the problem statement
--Blank line---
.
.
.
--blank line---
Output for set n //As described in the problem statement
--end of file--

The USU online judge does not have multiple input programs like Valladolid. It prefers to give multiple files as input and sets a time limit for each set of input.

Problems of multiple input programs

There are some issues that you should consider differently for multiple input programs. Even if the input specification says that the input terminates with the end of file (EOF), each set of input is actually terminated by a blank line, except for the last one, which is terminated by the end of file. Also, be careful about the initialization of variables. If they are not properly initialized, your program may work for a single set of data but give correct output for multiple sets of data. All global variables are initialized to their corresponding zeros. Thus, for a single set of input, the initialization may not be necessary, but for multiple inputs, it is a must.

The Fixing Mistake section

Always be sure to see the Fixing Mistake section of the Valladolid online judge. Some of the problems in the Valladolid online judge have errors, which are corrected on this page.

Read the message board

Always try to read the message board of the Valladolid site. You will learn many things from other programmers. The USU online judge also has a message board. You can also submit your own views and problems via these boards.

Conclusion

Many people believe that the best programmer is the one with greatest knowledge of algorithms. However, problem-solving skills contribute to programming success as much as raw knowledge of algorithms. Don't lose your nerve during a contest, and always try to perform your best.

References

1
Astrachan, O., V. Khera, and D. Kotz. The Internet Programming Contest: A Report and Philosophy
2
Chowdhury, R. A., and S. Manzoor. Orientation: National Computer Programming Contest 2000, Bangladesh National Programming Contest, 2000.
3
Ernst, F., J. Moelands, and S. Pieterse. Teamwork in Programming Contests: 3 * 1 = 4, Crossroads, 3.2.
4
Kaykobad, M. Bangladeshi Students in the ACM ICPC and World Championships, Computer Weekly.
5
Poucher, W. B. ACM-ICPC 2001, RCD Remarks, RCD Meeting of World Finals 2001.
6
Verhoeff, T. Guidelines for Producing a Programming-Contest Problem Set: http://wwwpa.win.tue.nl/wstomv/publications/guidelines.html

 

Useful Links

ACM Home Page: http://www.acm.org/
ACM International Collegiate Programming Contest Problem Set Archive:
http://www.acm.inf.ethz.ch/ProblemSetArchive.html
ACM International Collegiate Programming Contest Web page:
http://acm.baylor.edu/acmicpc/
American Computer Science League (ACSL) Homepage:
http://www.acsl.org/acsl/
Centrinës Europos informatikos olimpiados (CEOI) Resource Page:
http://aldona.mii.lt/pms/olimp/tarpt/ceoi.html
Informatics Competitions Link Page:
http://olympiads.win.tue.nl/ioi/misc/other.html
Internet Problem Solving Contest (IPSC) web page:
http://ipsc.ksp.sk/
International Olympiad in Informatics (IOI) web page:
http://olympiads.win.tue.nl/ioi/index.html
Mark Dettinger's Home Page:
http://www.informatik.uni-ulm.de/pm/mitarbeiter/mark/
New POTM Master's Home Page:
http://contest.uvarov.ru/
PC2 Home Page:
http://www.ecs.csus.edu/pc2/
POTM Master's Home Page:
http://members.tripod.com/~POTM/fah_home.html
Ural State University (USU) Problem Set Archive with Online Judge System:
http://acm.timus.ru/
University Waterloo Contest Page:
http://plg.uwaterloo.ca/~acm00/
Valladolid 24-hour Online Judge :
http://acm.uva.es/problemset
Valladolid Online Contest Hosting System:
http://acm.uva.es/contest
Valladolid Problems link:
104, 120, 135, 371, 336, 466, 497.

 

Biography

Shahriar Manzoor (shahriar@neksus.com) is a BSc student of Bangladesh University of Engineering & Technology (BUET). He participated in the 1999 ACM Regional Contest in Dhaka, and his team was ranked third. He is a very successful contest organizer. He has arranged six online contests for the Valladolid online judge including the "World Final Warm-up Contest." His research interests are contests, algorithms, and Web-based applications.

Acknowledgements

Shahriar Manzoor is grateful to Prof. Miguel A. Revilla for letting him arrange online contests and to Prof. William B. Poucher for asking people to participate in the World Final Warm-up Contest. He is also grateful to Ciriaco Garcia, Antonio Sanchez, F. P. Najera Cano, Fu Zhaohui, Dr. M. Kaykobad, Rezaul Alam Chowdhury, Munirul Abedin, Tanbir Ahmed, Reuber Guerra and above all his family.

 

CONTEST RULES

Contest Environment

Conduct of the Contest

Advice for Beginners

In this page, I would like to say a few things that you might be interested in making you a better programmer. You may disagree with me. That's fine. Everybody has their own opinion. However, I'm sure there are at least one thing that you will agree with me ^_^.

  1. In doing every problem, anything that the problem maker consider important.
    It might be something that you think is important or might not. Even the silliest thing can be an important thing.
  2. Do not make any assumption unless you have to.
    Say, if the problem statement doesn't state the limit of the input, don't assume that the limit is N. Ask first. If you don't get any satisfying answer, you may then assume (also take note of that assumption) or do as in Shahriar's advice (making a simple dummy program).
  3. Outline your program, say in pseudocode (daily language).
    This is an important issue. You may say that this is time consuming, etc., but by doing so, you usually eliminate any major mistake that may arise.
  4. Use variable names that you can relate to.
    Use wordy names if you have to, although it is not advisable especially in a time-limited competition. By doing this, you allow yourself to cut the time needed to figure out what the variables are for when you debug your program. I remember doing a contest in my early year as programmer. I used alphabet as my variables. If I am to explain that particular program today, I might not be able as I can't remember what they are for.
  5. Make simple comments at places you consider important.
    It has the same purpose.
  6. Use indentation and blank lines.
    Again, same purpose. However, when size does matter, you might want to eliminate all unnecessary blank spaces.
  7. Watch out for any limitation.
    Still fresh in my mind, I used signed 16-bit integer for a problem where the input can go up to 50000. That particular mistake made me lose the entire problem.
  8. In connection with above, use the largest possible variable type.
    Watch out though, if the problem specifies integer, you use integer type, not floating-point type. This advice only applicable when there is no or extremely big space-limit. As you grow, you may find this particular advice unimportant. The smaller the variable type, the faster the program run.
    Simple example, compare adding two 32-bit integers and two 16-bit integers. The former need 32 adding process while the latter only need 16 adding process. Of course, you have to watch out for the limit.
  9. In a competition, watch out for execution-time limit.
    Efficiency is important. But also take this into mind, don't be too efficient if it makes the program a lot complicated. Always try to be simple. If you find that your program too slow, first of all try to think for another way. If you can't find any, you then develop short cuts.
  10. Get used to the platform.
    From what I heard, using "Enter" can give different results in different platform. Say on Linux, you might only get CR (Carriage Return), but on Unix, you might get LF (Line Feeder) or the other way around, I don't really remember. This can get really annoying especially in reading the input. There shouldn't be any big trouble for C users, but for Pascal users, say "bye bye" to ReadLn.
  11. End of Input <> End of File!!!
    This is very tricky. I've found at least 7 different types of input. The one with additional character after the end of the input, the one with no LF character, the one without CR character, etc. The best way to get used to this problem, is to follow the advice below.
  12. Practice, practice and practice. I know, this is the most ... part, but still it's unavoidable. If there is any short cut, I would have taken it. :(

Say, if you have any comments or any addition you would like to make, you are welcome to do so. E-mail me at IlhamWK@themail.com.

© 2000 Ilham W. Kurnia

 

THE ONLINE JUDGE ANSWERS

A few seconds after sending the E-Mail with your program, you'll receive a confirmation reply by E-Mail from the judge system (unless you have selected not to receive replies by E-Mail: note that there is enough information in the Web, updated in real time).

Your program will be compiled and run in our system, and the automatic judge will test it with some inputs and outputs, or perhaps with a specific judge tool. After some seconds or minutes, you'll receive by E-Mail (or you'll see in the Web) one of these answers:

All E-Mails received and the results of their actions are logged; this would allow us to detect any possible intention to use the judge for incorrect purposes. If you submit several programs for the same problem and you get several accepted messages for it, you'll appear in the ranklist only with your better solution (less CPU time and/or memory spent).

Guidelines for Producing
a Programming-Contest Problem Set

Tom Verhoeff

Faculty of Mathematics and Computing Science
Eindhoven University of Technology
P.O. Box 513, NL-5600 MB Eindhoven, The Netherlands
E-mail:
Tom.Verhoeff@acm.org

October 1988, Revised and expanded July 1990

Abstract

In this note we give some guidelines to produce a problem set for ``ACM-style'' programming contests, in particular for the European Regional Programming Contest. The reader is assumed to be familiar with the operation of such programming contests. Where possible, we also explain the motivation behind the guidelines.
The first two sections deal with aspects related to the problem set as a whole, viz. requirements and production schedule. They are especially intended for the Head Judge. The remaining sections cover the following aspects concerning individual problems in the problem set: selection, specification, solution, and testing. These sections are more directed towards the Problem Creators.


A good problem set is the key to a successful programming contest. The production of such a problem set should be taken very seriously and requires a major effort by a number of people. The guidelines presented in this note should enable you to do a good and enjoyable job.

Problem set requirements

The Head Judge is responsible for the timely production of a suitable problem set. In the contest, each team should be provided with two (2) copies of the problem set.

The problem set consists of at least six (6) problems. There should be sufficient variation in both the difficulty and the computational aspects of the problems. Two (2) easy problems and one (1) more difficult problem should be included. All problems should be original in some respect. For example, a problem can be new as such, or its embedding into a context can be new, or its boundary conditions can be new.

The reason for having at least six problems is that we prefer to measure the strength of teams by number of problems solved and not by amount of time spent on solving them. (Recall that ranking is done first on account of number of problems solved and, in case of a tie, on account of time spent.) To provide sufficient resolution, the problem set should be so large that the strongest team can solve (almost) all problems just in time. Of course, the number of competing teams, the difficulty of the problems, and the duration of the contest are also important factors. At the Finals (a six-hour contest with 24 teams; five hours since 1990, and over 50 teams in 1998.) typically eight problems were posed with satisfactory results. The reasons to include at least two easy problems are the following.

  1. Easy problems can serve as starters and allow early usage of the PC (this requires that the teams make the right judgment about difficulty; hence, assessment of problem difficulty is an important aspect of the contest).
  2. Weak teams should have some fun too; therefore, they should be enabled to solve---not just work on---some problems.
  3. Strong teams should be able to solve easy problems quickly (say, in half an hour), which acts as an incentive for themselves and others (including judges etc.).
  4. Teams solving no problems cannot be differentiated in the final ranking, whereas teams that solved at least one problem can be ranked according to time spent.

The presence of one or two more difficult problems serves to differentiate the strongest teams on account of the number of problems solved and not just on account of time spent. Furthermore, difficult problems make the contest more interesting: we would not want the contest to degrade to mere implementation jobs.

We know from experience that it is unlikely that an interesting problem is too easy. (Keep in mind that teams usually read all problems first and need to decide on an appropriate order to solve them, before they start programming. Hence, it unlikely that a problem is solved within 15 minutes.) Moreover a problem can readily be made more difficult; making it easier is often painful. Also note that it hardly makes sense to include problems that are too difficult. The only thing that the presence of a too difficult problem can measure is the ability of the teams to recognize and then ignore the problem. This is not worthwhile the trouble of including such a problem.

The reason to cover various computational aspects are the following.

  1. If one aspect (say, juggling with dates or numerical approximation) appears in many of the problems, then ``specialists'' in that field have an advantage.
  2. Variation allows teams to work on those types of problem they like most (only strong teams will have little choice: they should solve all problems). On the other hand, a nice thing about two problems with a common aspect is that a team recognizing this fact may benefit by writing a combined solution.

The reasons for having original problems are

  1. to make the contest interesting for the contestants and the organizers,
  2. to avoid giving unfair advantage to teams familiar with particular problems, and
  3. to attract some attention from the Computing Science community.

Each problem must have a short and unambiguous identifier, for instance, a letter. This identifier will also be used on the Run Envelopes, Clarification Requests, and Standings. The cover page of the problem set mentions the date, the number of problems, their identifiers, and the number of pages. For example,

This is the problem set for the
1990--91 European Regional Programming Contest
held on Saturday November 3, 1990.
It contains 7 problems labeled A through G
printed on 10 numbered pages.

Production schedule

The following phases can be distinguished in the production of a problem set.

  1. Generate ideas for problems, making explicit what the crucial computational aspect is of each problem.
  2. Select initial set, taking into account the need for originality and variation in difficulty and computational aspects, and eliminating too difficult problems.
  3. Specify problems in detail.
  4. Write complete programs for problems (including alternative solutions where necessary).
  5. Write input validator and output verifier.
  6. Produce test input data files (and test output data files where necessary).
  7. Validate examples, validate test data, check spelling.
  8. Print a sufficient number of copies of the problem set.

Each phase should take no more than one week to complete. We suggest that you have a review meeting at the end of each phase.

The Head Judge needs to take into account that only afterwards a problem may turn out to be unsuitable. Initially, aim at eight or even nine problems. In the 1989--90 European Regional we posed all nine problems that we had prepared (none had to be abandoned) and, contrary to our expectations, one team was able to solve all nine of them!

See to it that for each problem there is one person taking full responsibility for all aspects (this would usually include judging as well). Of course, it is also a good idea to have Problem Creators read each other's specifications and possibly even attempt solutions.

Problem selection

Here are some facts to keep in mind when creating a problem.

Each team consists of up to four (4) programmers (usually computing science students at undergraduate or graduate level). They have one (1) personal computer with Turbo Pascal 5.5 at their disposal and they may consult non-computer-readable literature and non-programmable calculators. The contest lasts six (6) hours. However, for the Finals that will now be five hours. By the way, they reduced the length of the Finals so that

  1. there would be more excitement at the end of the contest.
  2. it would be less likely that the winners be known prior to the Banquet.
  3. teams not making much progress would feel less frustrated.
  4. judges would not feel compelled to increase the number of problems (compensating for the increased power of modern software development environments).
  5. judges would be less tired and less likely to err.
  6. five hours fits nicely between 1pm and 6pm.

Judging is done by running the submitted program for some test cases and subsequently checking its output. A program is either accepted or rejected. In the latter case, the team is given a 20 minutes' penalty for the problem and one of the following reasons for rejection is indicated:

  1. Syntax Error
  2. Run-Time Error
  3. Time-Limit Exceeded
  4. Wrong Answer
  5. Failed Test Case
  6. Inaccurate Answer
  7. Too Little/Much Output
  8. Bad Output Format
  9. Check Clarifications

The run-time limit is three (3) minutes unless otherwise indicated in the problem specification. There is still some controversy over these messages. We will come back to them in the section on testing.

A problem may be interesting for several reasons. Important aspects can be

Problem specification

Problems will be posed in English. Each problem prescribes the names of the program source file and the data input and output files. Since judges recompile the program there is no need to mention the name of an executable file. A problem may require more than one input and/or output file. An execution time-limit is mentioned if it deviates from the standard amount (see above).

The problem specification will usually start with a story and the introduction of some concepts, possibly accompanied by instructive examples. This is followed by a short informal description of the programming task and then a more precise specification of input and output format and their desired relation. Finally, an example input set with corresponding output is given.

Of course, the aim is to specify a problem completely and unambiguously. Although teams may make clarification requests, it is better to obviate these by a careful problem specification. Keep in mind that English is a second language for most of the teams. Also keep in mind that long specifications tend to be more controversial than concise ones.

The following example was adapted from the 1989--90 Finals held in Washington D.C., USA.

Problem A

Rare Order

Source

ORDER.PAS

Input

ORDER.DAT

Output

ORDER.OUT

A rare book collector recently discovered a book written in an unfamiliar language that used the same characters as the English language. The book contained a short index, but the ordering of the items in the index was different from what one would expect if the characters were ordered the same way as in the English alphabet. The collector tried to use the index to determine the ordering of characters (i.e., the collating sequence) of the strange alphabet, then gave up with frustration at the tedium of the task. You are to write a program to complete the collector's work. In particular, your program will take a set of strings that has been sorted according to a particular collating sequence and determine what that sequence is.
Input The input consists of an ordered list of strings of uppercase letters, one string per line. Each string contains at most 20 characters. The end of the list is signalled by a line that is the single character '#'. Not all letters are necessarily used, but the list will imply a complete ordering among those letters that are used. A sample input file is shown below.
XWY
ZX
ZXY
ZXW
YWWX
#
Output Your output should be a single line containing uppercase letters in the order that specifies the collating sequence used to produce the input data file. Correct output for the input data file above is shown below.
XZYW
End of Problem A

This is a nice and inviting problem with a concise specification. However, it might not be completely clear to the contestants whether the input file may contain empty strings (at the very beginning only, since it is sorted) and whether the file may consist of the end-of-list marker '#' only. As a Problem Creator you should be aware of these extremes.

The Problem Creator should summarize the crucial computational aspects of the problem for the Head Judge. In this summary, tricky issues, boundary cases, and required efficiency considerations may be mentioned. Of course, the summary should not be revealed to the contestants until after the contest. For the above sample problem the following summary might be produced.

Problem A (Rare Order): Summary of computational aspects.
Let R be the total order induced by the collating sequence that was used to sort the input file. It is R that has to be reconstructed from the input.
Algorithm For two strings s and t, the following holds: either (a) one string is a prefix of the other, or (b) for some index k we have s[i]=t[i] for all i<k and s[k] <> t[k]. Which of (a) or (b) holds and, if (b) holds, what the index k is, can be determined independent of R. The required procedure is a variant to determining the lexicographic order of two strings.
Therefore, each pair of strings s and t, where s precedes t in the input file and s is not a prefix of t, contributes to our knowledge about R, viz. s[k] R t[k] (because precedence in the input file is based on the lexicographic order). One needs to consider only neighboring strings in the input file, since other pairs will not provide new information about R.
The input can be scanned once sequentially to collect all information about R, for example, in a NxN-matrix, where N is the number of letters in the alphabet (N=26 always works). For the sample input provided in the specification this matrix might look like

R

W

X

Y

Z

W

 

 

 

 

X

 

 

 

1

Y

3

 

 

 

Z

 

 

4

 

where the number n at entry (a,b) indicates that a R b holds on account of input lines n and n+1. This matrix must completely determine R (as promised in the specification). The collating sequence can now be extracted in several ways (e.g. repeatedly find minimal element and remove it; the example matrix above is atypical in that each column has at most one non-blank entry). Of course, one should consider only letters that occur in the input. Keeping track of some additional information (e.g. the number of non-blank entries per column) may speed things up.
Special cases Duplicate strings and empty strings may be present in the input file. Their presence may slightly complicate the determination of index k mentioned above, but otherwise has no consequences. The input file may consists of the `end-of-list' marker only, in which case the output should be an empty collating sequence.
Input and output format are straightforward. No special efficiency considerations are required (other than noticing that to try out all collating sequences is hopelessly inefficient).

Problem solution

Once a problem has been specified it is necessary to obtain a better estimate of its suitability for the contest. This can be done by writing a complete program for the problem. That way one may encounter some trouble spots that otherwise would remain unnoticed.

It should take the Problem Creator, who is intimately familiar with the problem after specifying it, no more than a couple of hours to implement a working solution. That solution should be more or less along the lines of an ``intended'' solution and should not make use of implementation specific extensions to Pascal. It is not necessary to come up with a very neat and fully annotated solution (in case you still think that would be a waste of time). From this solution one can also determine some limits on run-time and memory utilization, which are useful when putting together test cases (discussed in the next section).

If it is the intention to rule out some straightforward solutions on account of their inefficiency (e.g. O(N3) instead of O(N)), then it is necessary to implement ``unintended'' alternative solutions as well. The alternative solutions must fail the tests (see below) even if they were otherwise cleverly coded, possibly using some implementation specific extensions to Pascal! You may sometimes be surprised how ``good'' unintended solutions turn out to be.

Apart from the bare ``intended'' solution it is also necessary to write another program. Input validation is not part of the contestants' programming task. That is, teams may assume that input supplied to their programs is in agreement with the specification. The Problem Creator, however, has to see to it that examples and test input data are valid. It is strongly recommended that input validation is done by a program. The input validator may be implemented as a separate program or may be incorporated in an ``embellished'' solution. N.B. The embellished solution need no longer be suitable for run-time and memory utilization assessment, so keep a copy of the original ``bare'' solution!

For Problem A (Rare Order) above, the input validator must check that each line but the last contains a string of at most 20 upper case letters and that the last line consists of a single '#'. Moreover it must determine that the input file is sorted according to a unique collating sequence. That is, leaving out the first string XWY should be detected as invalid (collating sequence not unique), as is the insertion of ZXZ after the first string (input not sorted). For Problem A it is convenient to incorporate the input validator in a solution.

Testing

Although we are interested in formally correct programs for the problems, judgment is based on testing. Hence, testability is an important issue.

If there is not much variety in the required output of a problem (e.g. only yes/no), then a program might ``unrightfully'' be accepted when it correctly ``guesses'' the output. Try to avoid this.

The test cases that are applied to exercise a program must allow a good assessment of the program's correctness. It may therefore be necessary to run more than one test case. Often it is convenient to specify the problem such that one input file actually allows a sequence of tests to be applied (this is not the case for Problem A above). Don't forget, however, that an execution time-limit must be set for the entire run (default unless otherwise stated).

Include both ``normal'' and special (boundary) cases in the test data. Determine the typical run-time of each test and mention it in your report to the Head Judge. For Problem A above, one would include the following input files among the tests: containing no strings (i.e., only the end-of-list marker '#'); in which all letters are the same; in which all 26 upper case letters appear; in which duplicate strings appear; in which strings that are prefixes of other strings appear; in which the directly deducible ordering relation is not a linear graph (e.g., by prepending the string XZ to the sample input: this directly implies the ordering Z R W, which is also obtained by transitivity from the other strings); containing strings of minimal and/or maximal length, differing only in certain positions; where both X R Z and Y R Z can be deduced before X and Y can be ordered; etc.

In order to generate test cases it is desirable to have a programmed solution for your problem. In order to judge a program it is convenient to have an output verification program. This verifier takes the output of the submitted program and checks it, e.g., against the output of a known correct program or/and with the aid of the input file. It may be convenient to specify the problem such that each input file produces a unique output file, in which case the evaluator can simply compare two files character by character (this is the case for Problem A above). Note, however, that in this case the output must be completely specified, taking into account such oddities as trailing blanks, leading zeroes, empty lines, etc. ``Normalization'' of output text files before doing the output verification partly solves this problem (also see my note Additional Contest Information).

Of course, a simple file comparator cannot distinguish between such errors as Wrong Answer and Bad Output Format (but for the time being we do not mind). Currently, the error messages issued by the judges in the Finals when they reject a program are not sufficiently well-defined to be useful for automated judging. In particular, the messages Failed Test Case, Inaccurate Answer, Too Little/Much Output, Bad Output Format, and Check Clarifications are controversial. My suggestion is to ignore these possibilities. The teams will be told that these messages will not be issued. Hence, Wrong Answer covers any error not covered by Syntax Error, Run-Time Error, and Time-Limit Exceeded.

To get a good insight into the severity of the test cases it may be necessary to write yet another program that collects some statistics (to determine which situations occur how often). [Good example to be provided.] Like the input validator, this program could be a separate program or it could be incorporated in an ``embellished'' solution. It is sometimes also advisable to write a program that generates (possibly random) test cases with certain predetermined characteristics.

Summary

Aim at eight or nine original problems. Include two easy problems and one or two more difficult problems. Avoid too difficult problems. Cover various computational aspects. The best team should be able to solve (almost) all problems in the available time.

Each problem should fall under the responsibility of one person. For each problem the Head Judge needs to receive the following items from its Problem Creator:

  1. a specification,
  2. a short description of the crucial computational aspects,
  3. a programmed solution (possibly also alternative solutions),
  4. an input validation program,
  5. an output verification program (the verifier could be a simple file comparator for deterministic problems, in which case a test output data file must be provided), and
  6. a set of test input data files (preferably just one), including their typical run-time and some motivation for their discriminating power.

Items 1 and 2 are discussed in the section on Problem Specification, items 3 and 4 in section Problem Solution, items 5 and 6 in section Testing.

It would be nice if the Head Judge prepares solution suggestions to hand out after the contest. These could, for instance, be based on the ``description of crucial computational aspects'' as provided by the Problem Creators.

In case you want to organize contests more often, it is advisable to do an evaluation afterwards, in which you attempt to find out how well the objectives have been met. For instance, how difficult did the problems turn out to be, how many and which Clarification Requests were made, how well were the test cases, were any programs accepted unrightfully, were there any programs that got rejected because they failed on a single test case only, etc.

PROBLEM SET ARCHIVE
with ONLINE JUDGE

University of Valladolid (Spanish Judge) Online Judge contains past years ACM contest problems (either regional or finals) plus problems from another source. You can solve these problems and submit your solution to this Online Judge. The correctness of your program will be reported as soon as possible. Try solving these problems and see your name on the top-200 author rank list :-)

Taken from USACO Training Gateway section 1.1.3 A good way to get a competitive edge is to write down a game plan for what you're going to do in a contest round. This will help you script out your actions, in terms of what to do both when things go right and when things go wrong. This way you can spend your thinking time in the round figuring out programming problems and not trying to figure out what the heck you should do next... it's sort of like PreComputing your reactions to most situations.

Mental preparation is also important. Game Plan For A Contest Round

Read through all the problems first; sketch notes with algorithm, complexity, the numbers, data structures, tricky details, ...

Coding a problem - For each, one at a time:

Time management strategy and "damage control" scenarios

Have a plan for what to do when various (foreseeable!) things go wrong; imagine problems you might have and figure out how you want to react. The central question is: "When do you spend more time debugging a program, and when do you cut your losses and move on?". Consider these issues:

Have a checklist to use before turning in your solutions:

Tips & Tricks

Complexity

Basics and order notation

The fundamental basis of complexity analysis revolves around the notion of ``big oh'' notation, for instance: O(N). This means that the algorithm's execution speed or memory usage will double when the problem size doubles. An algorithm of O(N^2) will run about four times slower (or use 4x more space) when the problem size doubles. Constant-time or space algorithms are denoted O(1). This concept applies to time and space both; here we will concentrate discussion on time. One deduces the O() run time of a program by examining its loops. The most nested (and hence slowest) loop dominates the run time and is the only one mentioned when discussing O() notation. A program with a single loop and a nested loop (presumably loops that execute N times each) is O(N^2), even though there is also a O(N) loop present. Of course, recursion also counts as a loop and recursive programs can have orders like O(b N), O(N!), or even O(N^N). Rules of thumb

Examples

A single loop with N iterations is O(N):

1 sum = 0
2 for i = 1 to n
3 sum = sum + i
A double nested loop is often O(N^2):

# fill array a with N elements
1 for i = 1 to n-1
2 for j = i + 1 to n
3 if (a[i] > a[j])
4 swap (a[i], a[j])

Note that even though this loop executes N*(N+1) / 2 iterations of the if statement, it is O(N^2) since doubling N quadruples the execution times.

Consider this well balanced binary tree with three levels:

* ----- Level 1
/ \
* * ---- Level 2
/ \ / \
* ** * -- Level 3
An algorithm that traverses a general binary tree will have complexity O(2^N).

Solution Paradigms

Generating vs. Filtering

Programs that generate lots of possible answers and then choose the ones that are correct (imagine an 8-queen solver) are filters. Those that hone in exactly on the correct answer without any false starts are generators. Generally, filters are easier (faster) to code and run slower. Do the math to see if a filter is good enough or if you need to try and create a generator. PreComputation / PreCalculation

Sometimes it is helpful to generate tables or other data structures that enable the fastest possible lookup of a result. This is called PreComputation (in which one trades space for time). One might either compile PreComputed data into a program, calculate it when the program starts, or just remember results as you compute them. A program that must translate letters from upper to lower case when they are in upper case can do a very fast table lookup that requires no conditionals, for example. Contest problems often use prime numbers - many times it is practical to generate a long list of primes for use elsewhere in a program. Decomposition (The Hardest Thing at Programming Contests)

While there are fewer than 20 basic algorithms used in contest problems, the challenge of combination problems that require a combination of two algorithms for solution is daunting. Try to separate the cues from different parts of the problem so that you can combine one algorithm with a loop or with another algorithm to solve different parts of the problem independently. Note that sometimes you can use the same algorithm twice on different (independent!) parts of your data to significantly improve your running time. Symmetries

Many problems have symmetries (e.g., distance between a pair of points is often the same either way you traverse the points). Symmetries can be 2-way, 4-way, 8-way, and more. Try to exploit symmetries to reduce execution time. For instance, with 4-way symmetry, you solve only one fourth of the problem and then write down the four solutions that share symmetry with the single answer (look out for self-symmetric solutions which should only be output once or twice, of course). Forward vs. Backward

Surprisingly, many contest problems work far better when solved backwards than when using a frontal attack. Be on the lookout for processing data in reverse order or building an attack that looks at the data in some order or fashion other than the obvious.

Simplification

Some problems can be rephrased into a somewhat different problem such that if you solve the new problem, you either already have or can easily find the solution to the original one; of course, you should solve the easier of the two only. Alternatively, like induction, for some problems one can make a small change to the solution of a slightly smaller problem to find the full answer.

We have a variety of programming languages in this world. In this section I want to give a comparison between C, Java and Pascal

C

Java

Pascal

Assignment

a=7;

a=7;

a:=7;

Comparison

if (a==b)

if (a==b)

if a=b then

For loop

for (int ct1=0;ct1<=7;ct1++)
very flexible

for (int ct1=0;ct1<=7;ct1++)
very flexible

for ct1=0 to 7 do
not flexible

While loop

while (ct1==7)

while (ct1==7)

while (ct1=7) do

Block statement

{
statements;
}

{
statements;
}

begin
statements;
end;

Speed

Fastest

Slowest

Medium

EXE/class size

Big

Medium

Smallest

Popularity

Still popular

Increasing popularity

Decreasing popularity

Shortcuts

Many, a++,b--;a+=b; etc

Many, a++,b--;a+=b; etc

None, only Inc(a); Dec(b);

Boolean Algebra

a && b, a || b, !a

a && b, a || b, !a

a and b, a or b, not a

Library

#include <stdio.h>

import java.io.*;

uses crt;

OOP

No, only in C++

Yes

No

Input/Output

scanf,printf

System.out.println

readln,writeln

Array

int arr[7];

int[] arr = new int[7];

var arr:array[1..7] of integer;

My preference

Best language

Don't like this because I haven't found a good debugger.

Second best

Alias: Ackermann Function or Collatz Sequence

Any number can be reduced to 1 using this algorithm.

while (n!=1)
{
if n is odd then
n=3*n+1
else
n=n/2
}
Sample: Ackermann function of (11) = 11-34-17-52-26-13-40-20-10-5-16-8-4-2-1

It's about how to place 8 queens on 8x8 chess board so that no queen can attack any other queen.

There are 92 possibilities to do so, don't believe it? then read on.

First strategy is to guess a solution... How many ways to arrange 8 queens on a 8x8 chessboard? Unfortunately, there are 4 426 165 368 ways to do so, too many.

Next approach is that no queen can reside in a row or a column that contain another queen, In other words, each row and column can contain exactly one queen, this reduce the possibility to 8! = 40 320 possible arrangements. This one is quite reasonable.

The best solution is to use backtracking (recursive). If a particular guess leads to a dead end, you go back and then try another solution.

I have heard this following Computer Science terms, but still don't know what is that about (or still don't know how to explain these): Red-Black-Trees, How to create effective permutations, how to anagramming a word, using convex hull algorithm, and many more... If someone who see this web pages know something that I don't know yet, send your ideas through this feedback form. I'll appreciate your comments

 

ACM Programming Contest

This is my Web page for the ACM Programming Contest and Calvin's teams.

Format of the Contest

Your team will be given one computer to use. You can use it only to write your programs.

You will also be given a work area. Depending on the contest site, you may or may not have a chalk- or white-board available for your team. You should plan on using paper (which may or may not be provided).

During the five hours of the contest, your team will have to write six (or more) programs. When you submit a program, judges will compile and execute your code on some test data. You will get to see only a (very) small portion of this test data.

If your program works fine, you are given a score based on the elapsed time since the beginning of the contest. If your program fails, the judges will notify you of this and give you an extremely generic comment like "Bad format of output" or "Incorrect output". They will not tell you how the format is bad or how the output is incorrect. You can submit the program as many times as is needed, but each time it is rejected, you are given a time penalty for that problem.

The team that solves the most problems in the least amount of time (including time penalties) wins.

Judges can only answer questions of procedure or clarification. They cannot answer questions about what's wrong with your program.

Contest Site

We'll be competing at Western Michigan University in Kalamazoo. There's no word yet on the environment you'll be using there. In 2000, at Case Western University, the computers had (crippled?) Mandrake Linux installed on the computers.

Helpful Links

My Suggestions

Good Design and Programming Style

The key to this contest is writing programs quickly. This implies quick-and-dirty solutions. While this means you maybe shouldn't spend the time on a full Object Centered Design a la CPSC 185, don't abandon design and programming style all together. Good design and good programming style lead to good programs; sacrifice them too much at your own debugging peril.

Keep in mind that the judges never look at your code. (Well, they might if they're curious, but it won't affect their acceptance of the program, and they won't say anything about it.) The look and design of the program matters only to you. So do enough so that it's easy for you and your teammates to debug, but not any more than that.

You probably should not even worry about separate file compilation. Just put everything into one file the easiest way you can.

You should work out a consistent style with your teammates since you'll (most likely) have to read and debug each other's code.

Input and Output

Do not program for bad input unless the problem specificly asks for it. (I'd be very surprised in any problem did ask for error handling.) Your program will be tested only with good data.

Write a few programs (based on the problems from previous contests) before the contest that merely read in different intput formats. Print off copies of these programs so that you have them with you during the contest. Actually do this. No, I'm completely serious. If you do nothing else, at least have a library of programs that handle a variety of I/O. It will not be enough that you get the code from someone else because you will have to work through the code during the contest. You cannot afford to spend time looking up the perculiarities of I/O routines.

Choosing What Problem to Solve

Use your best judgement in terms of what problems are the easiest to solve. After a few teams have solved a problem or two, check the results. It's pretty obvious after a while which problem (or problems) are the easiest.

If you're not already working on that problem, I'm inclined to suggest that you immediately switch over to the easy problem as identified by those other teams if you're not already working on it. There are obvious drawbacks to this, and it does depend on how far you are on whatever problems you're already working on.

Organizing Your Team

I'm unsure what's the best way to organize teams, but the Crossroads article linked above seems to have some good ideas. Discuss team strategies with your team. The Think Tank approach sounds the best to me, but you have to train for it.

Technical Issues

The Environment

My guess is that you'll be able to configure you're environment during the practice contest on Friday night. So you should be able to type in (or perhaps copy) editor configuration files and the like. Bring printed copies of these configuration files in case the computers are not connected to the Internet.

I would take: .emacs, .bashrc, .bash_profile. (Actually, I'd probably have to whittle them down a bit.) Substitude in your own files based on your preferences. Are there other configuration files that would be useful?

Programming Issues

Here are some issues that have been important in other contests I've seen.

Floating Point Computations

Never, ever test equality of two floating point numbers. Floating point computations are inherently inaccurate, so just simply using == in C/C++/Java is a Bad Idea. Your computation will probably never exactly equal the target value. Instead, test to see if your computed value is close to the target value.

For example, you may need to see if x equals y. Instead of if (x == y) you should write

if (fabs (x-y) < 1e-15)

This tests to see if x is within 10^{-15} of 0.0. This range is appropriate for double precision floating point values. Use 10^{-8} for single precision floats. Usually the problem specification in the contest will tell you what tollerance you should use.

Be sure to include <math.h> so that fabs() works correctly. Also, in UNIX, be sure to compile with the -lm flag.


Last modified: Wed Sep 26 15:33:43 EDT 2001
This document was prepared with
Latte, the best text processing language for the Web.
© Copyright 2000,
Jeremy D. Frens & Calvin College. Permission to copy by any means is granted as long as this copyright is preserved.

1