IOI'97 Competition Rules

The Competition Week

IOI'97 takes place from Sunday, 30th November (arrival day) to Sunday, 7th December (departure day). Tuesday 2nd December and Thursday 4th December are the competition days. On each of these days you will be given three programming tasks to complete in the five hours from 08:00 to 13:00.

Competition Equipment

The competition computers will be ICL or Compaq PCs, of identical specifications, with a standard US keyboard, a mouse and a colour screen.

Diskettes for back-ups and printing, blank writing paper, pens, pencils and erasers will be provided. You may NOT take any aids of your own, such as program disks, calculators, manuals or books, into the competition room.

Programming Languages

The following will be installed on each computer:

  1. MS-DOS Version 6.22
  2. Borland Pascal Version 7.0
  3. Borland C++ Version 3.0
  4. Quick Basic Version 4.5

All the packages will be fully installed with help files.

Directories and Execution Path

You will find the following directories on the hard drive of your computer:

  1. C:\TP for Borland Turbo Pascal
  2. C:\TC for Borland Turbo C++
  3. C:\QB for Quick Basic
  4. C:\Day1 for the task directories of day 1
  5. C:\Day2 for the task directories of day 2

The execution path %PATH% will be set to give access to all programming languages.


You will be able to use any of the competition labs for practice. The labs will be available from 13:00 on Saturday 29th November until 21:00 on Monday 1st December, and on Wednesday 3rd December from 16:00 until 21:00. The standard competition environment will be provided together with other facilities such as e-mail. Prior to the competition all competition computers will be re-formatted and loaded with the standard competition environment described above. For the competition, computers will be assigned randomly to you.

Competition Tasks

All of the tasks at IOI'97 are programming tasks and are designed to be of an algorithmic nature. The focus is on designing correct and efficient algorithms.

For each task, the task overview page gives a task name, a directory name, input and output files, the execution time limit that applies to every test run and the maximum points awarded for the task.

For each task you will get two descriptions: one in English and the other translated into your native language by your delegation leader. All relevant figures and examples in the English original are numbered. The translated versions should refer to these figures by their number; captions may be translated.

All relevant figures and examples in the English original as well as the English text are binding and official.


Some of the programming tasks have subtasks and points are awarded for each subtask. Subtasks may call for separate functionality or simply require you to handle more complex input data.

Your Programs

While you may choose to write your programs in any of the programming languages offered, to enable objective judging you must compile your programs as stand-alone MS-DOS executables.

The programming tasks can all be solved in any of the programming languages offered. The input and output operations will be kept simple, allowing you to concentrate on the algorithmic details. No special features of the programming packages are needed, nor should they be used. In particular, the following features will NOT play a role in the programming tasks and are discouraged:

Graphical output, mouse input, advanced file manipulation, advanced numeric processing and DOS calls.

You should be familiar with the programming package of your choice, including the use of libraries or units. Your ability to use the Integrated Development Environment (IDE), in particular, the built-in editor, compiler and the debugger, will be helpful. Some knowledge of compiler options may also be an advantage. Furthermore, you should be able to use MS-DOS for such tasks as executing a program, changing the working directory and managing files.

External Communication

The only external communication allowed by your program is reading input files, writing output files and calling external functions in libraries, that are specified in the task descriptions.

In particular, you are not allowed to write to the serial ports or attempt to change the timer clock. Any attempt to do so will result in disqualification and a score of 0.

Input Data

Programs should read their input data from ASCII text files. This is the case even if the program needs only a single value. The names of the input files are given in the task description. The names of the input and output files must be spelt precisely as given; no variation will be allowed. Programs must not read from the keyboard.

You may assume that the input data agrees with the task description. You should, however, always validate the input data in your program.

Input data consists of a sequence of items. An item is either an integer or a non-empty character string of letters ('a' to 'z' and 'A'to 'Z') and/or ('0' to '&'). Items are separated by either a single space character or a single end-of-line.

In general the structure of the input is such that you do not have to worry about end-of-file conditions. There may, however, be exceptions to this.

Examples of input files are provided for all tasks, both in the task description and the task directory.

Output Data

Programs should write their output data to the ASCII text file specified in the task description. Programs are NOT required to write to the screen, and such output will NOT be evaluated. You are encouraged to remove all screen output from your programs before you create the final executable.

Output data consists of a sequence of items. An item is either an integer or a non-empty character string of letters ('a'to 'z' and 'A' to 'Z') and/or ('0' to '9'). Items are separated by either a single space character or a single end-of-line.

The output should be formatted exactly as shown in the task description. Never add output of your own, as this may disrupt the evaluation process.

Exit Code

Your program should terminate "normally" (i.e. with an exit of code 0).

In particular, C and C++ programmers should explicitly return 0.

Starting the Competition

You will be allocated a Laboratory for the duration of the competition. When you enter the competition room, your allocated computer will already have been switched on. Your competition entry code will appear in large letters on the screen. The competition task descriptions will be inside a folder underneath the keyboard.

Do not touch the keyboard or open the folder until the start signal is given.


During the first hour of the competition (08:00 to 09:00) you may submit written questions concerning any possible obscurities or ambiguities in the competition tasks. These questions will be answered by only one of the following:

`Yes', `No', or `No Comment'.

You must submit your question(s) on the "Question Form" provided, in English or your native language. If required, the question(s) will be translated into English by your delegation leader.

The Scientific Committee will answer every question submitted by the contestants. This may take some time, so you should continue working while waiting for the answer to your question(s). You will not be involved in discussion.

You may ask the lab supervisors for assistance at any time. The supervisors will NOT answer questions about the competition tasks, but will deliver your question forms, help you find toilets, refreshments and attend to computer problems.


During the competition you will be able to get printouts of ASCII files. Copy the file(s) into the subdirectory "A:\PRINT" of your diskette and hand it to the supervisor. Your diskette will be returned with the printout of the file(s). The file(s) will be moved to the directory "A:\TRASH", after printing.


You will be provided with a diskette to backup your files during the competition. You are advised to maintain backups, so that you can recover in the unlikely event of a machine failure.

Ending the Competition

You will be warned at 15 and at 5 minutes before the end of the day's competition. Take this opportunity to go through the following check list for the tasks:

  1. Have you saved your programs with the correct name in the correct task directory? (No other files or directories will be evaluated).
  2. Have you disabled the debug features in your programs?
  3. Have you removed screen output?
  4. Did you make executables using the right compiler options?
  5. Did your programs produce output in acceptable formats?

At the END signal, you must immediately stop working. Put your keyboard on top of the monitor.

Do NOT switch off your computer. The supervisors will make a backup of your work.

You may NOT remove any diskettes from the competition room. You may remove your competition folder.


Judging starts one and a half hours after the competition ends. Your delegation leader will be given a schedule showing when you can expect to have your work evaluated. You and your delegation leader will be asked by an evaluator to observe the judging of your work on your competition computer.

Judging of a program involves several "test runs" with confidential input data and special evaluation software. A test run for a program consists of the following steps:

  1. Your executable program will be copied into a special evaluation directory.
  2. The test data will be copied to the appropriate file.
  3. Your program will be executed in this directory without command-line parameters.
  4. The execution will be timed by a separate computer.
  5. If your program terminates "normally" (with exit code 0) within the time limit, then the output is checked; otherwise it is aborted and the output will NOT be checked.
  6. The points awarded for each test run are aggregated to give your final score for that task.

Efficiency plays an important role in some tasks. Whenever efficiency is important, then at least one test run will be included where the input is such that a correct, but nevertheless inefficient, program can also score some points. It is important, therefore, to attempt a task even though you may not know how to achieve the `best' solution.

On completion of the evaluation your delegation leader will be asked to accept the results or register a request for further review giving a suitable reason. Your delegation leader will receive a copy of the diskette with your work and the test data used, and a printout of your results.