You are on page 1of 299

Olympiads

in Informatics

Olympiads
Olympiads
in
Informatics
in Informatics
Volume 10,
2016
Volume
10,
2016

J. ALEMANY FLOS, J. VILELLA VILAHUR


eSeeCode: Creating a Computer Language from Teaching Experiences

3
19

S. COMBFIS, G. BERESNEVIIUS, V. DAGIEN. Learning Programming through Games


and Contests: Overview, Characterisation and Discussion

39

. ERDSN NMETH, L. ZSAK


The Place of the Dynamic Programming Concept in the Progression of Contestants Thinking

61

S. GRTTER, D. GRAF, B. SCHMID


Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

73

J.I. GUNAWAN. Understanding Unsolvable Problem

87

J. HROMKOVI. Homo Informaticus Why Computer Science Fundamentals are an Unavoidable Part of Human Culture and How to Teach Them

99
111

M. KABTOV, I. KALA, M. TOMCSNYIOV. Programming in Slovak Primary Schools

125

E. KALINICENKO, M. OPMANIS. Collecting, Processing and Maintaining IOI Statistics

161

A. KARCZMARZ, J. CKI, A. POLAK, J. RADOSZEWSKI, J.O. WOJTASZCZYK


Distributed Tasks: Introducing Distributed Computing to Programming Competitions

177

M.M.I. LIEM. Reshaping Indonesian Students Training for IOI

195

W. Di LUIGI, G. FARINA, L. LAURA, U. NANNI, M. TEMPERINI, L. VERSARI


oii-web: an Interactive Online Programming Contest Training System

207

W. van der VEGT.


Bridging the Gap Between Bebras and Olympiad; Experiences from the Netherlands

223

T. VERHOEFF. Problem Solving, Presenting, and Programming: A Matter of Giving and Taking

231

REPORTS
M. DOLINSKY. Gomel Training School for Olympiads in Informatics

237

V. DUMANYAN, A. ANDREASYAN.
Armenia: IOI Participation and National Olympiads in Informatics

249

A. GREMALSCHI, A. PRISACARU, S. CORLAT.


Olympiads in Informatics in Republic of Moldova

255

A. IGLIKOV, M. KUTYBAYEV, B. MATKARIMOV. IOI 2015 Report

263

A. KHUDER, D. TSEDEVSUREN. The Informatics Olympiad in Mongolia: Training Resources for non-English Speaking Students

279

I. KIRYNOVICH, A. TOLSTSIKAU. Belarusian Olympiad in Informatics

285

ISSN 1822-7732

ISSN 1822-7732

Volume 10, 2016

J. HROMKOVI, T. KOHN, D. KOMM, G. SERAFINI


Examples of Algorithmic Thinking in Programming Education

Olympiads in Informatics

R. CASTRO, N. LEHMANN, J. PREZ, B. SUBERCASEAUX


Wavelet Trees for Competitive Programming

10

IOI

Inter

n at i

nal

Olym

piad

in

Infor

ics
m at

ISSN 1822-7732
INTERNATIONAL OLYMPIAD IN INFORMATICS
VILNIUS UNIVERSITY
INSTITUTE OF MATHEMATICS AND INFORMATICS

OLYMPIADS IN INFORMATICS
Volume 10 2016
Selected papers of
the International Conference joint with
the XXVIII International Olympiad in Informatics
Kazan, Rusia, 1219 August, 2016

OLYMPIADS IN INFORMATICS

Editor-in-Chief
Valentina Dagien
Vilnius University, Lithuania, valentina.dagiene@mii.vu.lt
Executive Editor
Richard Forster
British Informatics Olympiad, UK, forster@olympiad.org.uk
International Editorial Board
Benjamin Burton, University of Queensland, Australia, bab@maths.uq.edu.au
Michal Foriek, Comenius University, Bratislava, Slovakia, misof@ksp.sk
Gerald Futschek, Vienna University of Technology, Austria, futschek@ifs.tuwien.ac.at
Mile Jovanov, Sts. Cyril and Methodius University, Macedonia,
mile.jovanov@finki.ukim.mk
Marcin Kubica, Warsaw University, Poland, kubica@mimuw.edu.pl
Ville Leppnen, University of Turku, Finland, villelep@cs.utu.fi
Krassimir Manev, New Bulgarian University, Bulgaria, kmanev@nbu.bg
Seiichi Tani, Nihon University, Japan, tani.seiichi@nihon-u.ac.jp
Peter Taylor, University of Canberra, Australia, pjt013@gmail.com
Troy Vasiga, University of Waterloo, Canada, tmjvasiga@cs.uwaterloo.ca
Peter Waker, International Qualification Alliance, South Africa,
waker@interware.co.za
Willem van der Vegt, Windesheim University for Applied Sciences, The Netherlands,
w.van.der.vegt@windesheim.nl

The journal Olympiads in Informatics is an international open access journal devoted to


publishing original research of the highest quality in all aspects of learning and teaching
informatics through olympiads and other competitions.
http://ioinformatics.org/oi_index.shtml

ISSN 1822-7732 (Print)


2335-8955 (Online)

International Olympiad in Informatics, 2016


Vilnius University, 2016
All rights reserved

Olympiads in Informatics, 2016, Vol. 10, 12


2016 IOI, Vilnius University

Foreword
Time flies like an arrow
A popular example from the world of Artificial Intelligence (and Computational Linguistics), the phrase Time flies like an arrow is used to illustrate the ambiguity of language and the difficulty in comprehending structure. As a metaphor, it expresses how
quickly time passes. Study the syntax and you can argue that its an instruction to record
the movement of flies (perhaps in the manner of an arrow, or only those that are similar
to arrows), a description as to the preferences of a breed of fly, etc. Some interpretations have meaning, others less so, but underlying this is the message that something
apparently straightforward can have multiple meanings, nuances, interpretations. An
unexpected depth of meaning within a simple form.

IO
IO Informatics Olympiads. For those of us involved with national and international
olympiads there are numerous reasons why we got involved. For some, it has been
the challenge of competing: an opportunity to flex the intellectual muscles, a delight
in problem solving or even the pleasure of pushing yourself against other similarly
minded individuals. For others, it is the academic pursuit as the olympiads provide a
mechanism for learning and teaching: a way to practice skills and infuse knowledge; a
way to demonstrate that knowledge, skill and application to the wider world. Perhaps
for others it is the sense of community: fellow students, fellow educators, competitors
and friends. All of this before we even ask the question as why we stay involved.

10
There are, so says the old joke, 10 types of people in the world those who understand
binary and those who do not. In our modern world it is increasingly important to be
amongst those who understand. If we go back to the first days of the IOI, computer science was still a specialist pursuit. We had had a decade of home computers, so computers were accessible to many, and computing was appearing school curricula, but unless
you took an interest your exposure could be fleeting. We now exist in a world where
people carry powerful computers in their pockets ask yourself how many of the competitors at this years IOI carry a phone but do not wear a watch. So many facets of daily
life aided by computer programs, a many-headed beast that demands constantly to be

fed. It is not just teaching individuals how to program, most people will never write or
need to write a line of code, but an understanding of what is happening inside the black
box how things work, what is feasible, knowing what is going wrong to know how to
make things right is an important skill.

10
This is the 10th year for the Olympiads in Informatics journal. The first year when we
have publishing two volumes, as we are delighted to publish a special volume celebrating the informatics education of our host special thanks is given to the guest editor
Marina Tsvetkova. We have published a total of 185 papers showcasing 200 authors
from 50 countries. Technical papers and country reports. Algorithms and tasks. Reviews and opinions. The format of the journal is very similar to those early days; a
forum for those in the community to write about specialised technical issues, an opportunity to share our experiences and knowledge, and to give freedom for those who
are not academics to talk about their work. Looking back with the benefit of hindsight
we might have developed the journal in a different direction but, with that same knowledge, we can say that we have fulfilled (in the most part) the vision and aims that we
had when first establishing the conference.
Things are not always as they seem; it certainly does not seem like 10 years already.
Time flies like an arrow indeed.
There are individuals without whose tireless work this volume of the journal indeed every volume of the journal would not exist. As always, thanks are due to all
those who have assisted with the current volume authors, reviewers and editors. A lot
of work goes, not only to the writing of the papers, but to an extended period of review
and correction and, in several cases, translation. Peer viewing all of the papers takes a
significant amount of time and work and special thanks should be given to those otherwise unsung reviewing heroes: Benjamin Burton, Sbastien Combfis, Walter Gander, Gintautas Grigas, Mathias Hiron, Ville Leppnen, Pivi Kinnunen, Jari Koivisto,
Krassimir Manev, Martin Opmanis, Rein Prank, Jrat Skpien, Peter Taylor, Ahto
Truu, Willem van der Vegt. Particular thanks are due to the organisation committee for
IOI2016 in Russia without whose assistance we would be unable to hold the conference. Their assistance, during what is an already busy period, is gratefully received.
Editors

Olympiads in Informatics, 2016, Vol. 10, 318


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.01

eSeeCode: Creating a Computer Language


from Teaching Experiences
Joan ALEMANY FLOS1, Jacobo VILELLA VILAHUR2
Fundaci Aula: 34 Av. Mare de Du de Lorda, 08034 Barcelona Spain
Explorium: Samals 1 L3, 08530 La Garriga Spain
eSeeCode.com
2
Aula Escola Europea: 34 Av. Mare de Du de Lorda, 08034 Barcelona Spain
eSeeCode.com
e-mail: jalemany@eseecode.com, jvilella@eseecode.com
1

Abstract. It has been almost 50 years since the creation of Logo one of the first educational
programming languages. Although most people agreed that it was important to teach computational thinking to children, only recently have school and district leaders begun to adopt curricula
to include it mainly through Scratch. In many cases this adoption has failed to provide the right
methodologies and tools to teachers.
In this paper, we analyse some of the different languages used in classrooms today and we
propose an improved alternative that we have created eSeeCode. We also share our experiences
using this language in classrooms and how students can learn using this tool.
Keywords: informatics curriculum, promoting informatics, programming language.

1. Overview
Reading Paperts Mindstorms: Children, Computers, and great ideas, one can have the
feeling that we have not advanced much in the past 35 years (Papert, 1980). Many countries are trying to include Coding as a required skill to learn in schools, either as a specific subject or as part of a technology course. However, in many schools, teachers do
not have the resources, materials and/or knowledge to bring computer science and coding into the classroom. This is the case of Spain, among other countries, where computer
science has been introduced into the curriculum, but has failed to provide the details on
how to implement it properly, thus providing teachers the freedom and responsibility to
decide how to teach some basic computer science concepts (Saez-Lopez etal., 2016,
Ackovska etal., 2015, Duke etal., 2000).
In this paper, we will analyse several computer languages and materials, and we
will explain the difficulties students find when using them in class. As Edsger Dijkstra
explains, the selection of the programming language will influence how the students will

J. Alemany Flos, J. Vilella Vilahur

understand computer science (Dijkstra, 1999). We will base our examples on some of the
most popular computer languages used in Spain today, although this experience can be
extrapolated to many other countries.

1.1. Key Terms


To begin, we will use the term educational computer language in a broad sense, as a
programming language used to teach coding in classrooms, ranging from professional
computer languages such as C++ to puzzle-related languages as Lightbot. Because in
many cases language and programming environment cannot be analysed separately, we
will use them indistinguishably.
We will use the term text-based coding to describe languages that permit students to
type their own code, giving them total freedom in the expressions they write. In contrast,
we will use the term visual block based programming as the type of coding where you
select your own blocks, and build the programs with a drag-and-drop interface. There is
a fundamental difference when discussing the use of these languages in the classroom,
as the former, generally speaking, cannot prevent students from making syntax errors,
while the latter prevents these type of mistakes. Fig. 1 and Fig. 2 show different examples of text-based coding and visual block based programming.
We will differentiate between two kinds of paradigms when discussing different approaches to teaching. The first will be Problem Solving, where the teacher can present
the student a short, self-contained problem that needs to be answered. In the particular
case of this paradigm, we will also use the term Puzzle Solving. Similar in concept
to problem solving, we consider puzzle solving to have more of a recreational focus,
where there is a known set of rules that include multiple variations. For example, when
solving a sudoku puzzle there is a specific set of rules, and by changing the numbers

Fig. 1. Text-based coding example with Logo to create a square.

Fig. 2. Visual coding example with EV3 to make a Lego Robot move in a square pattern.

eSeeCode: Creating a Computer Language from Teaching Experiences

you change the problem. The teacher acts as a problem-setter or planifier, deciding
which problems to be solved at each moment, such as when a student is asked to code
the Eratosthenes sieve.
As an alternative to problem solving we find Project-based learning. In Spain, this
strategy is gaining increased attention in the school setting. As part of project-based
learning, students take a more active and creative role by pursuing an authentic and realworld project that addresses essential questions and works towards gaining an enduring
understanding of a relevant issue. The teacher here is more of a guide or facilitator that
helps the student when needed. In computer science this has the form of software design,
applied programming and modelling. For example, a student could work on solving the
problem of being able to identify a number as prime or not, with the project title being
Create a game that uses prime numbers.

1.2. Languages
To help keep the explanation focused, we have created a list of the main languages used
in schools in Spain, and have classified them by similarity of characteristics.
The final result is shown below:
Under text-based coding we will find two separate groups: the pure educational languages such as Logo or Processing, and the professional languages such as C++, Java,
Python and Javascript.
Under visual block based coding we find again two groups: educational languages
such as Scratch, Alice, Kodu, Ev3, AppInventor, and the group of puzzle languages
such as Lightbot and Beebot. Strictly speaking, Lightbot and Beebot are not complete
languages, but they are used to teach basic structures to students. It is for this reason that
we have decided to include them in our analysis.
Although each language has its own particular characteristic, we will analyse a representative of each group. The languages we have chosen are: Logo, C++, Scratch and
Lightbot.

2. Main Characteristics
To be able to compare the different languages we have created a short introduction for
each one.

2.1. Logo
Originally created by Wally Feurzeig and Seymour Papert in 1967, there are many versions of the language used in schools. Its main objective was to teach programming to
students from ages five to thirteen (Papert, 1980). Due to the fact that it has been around

J. Alemany Flos, J. Vilella Vilahur

for so long, there has been more than 300 versions of the language, with a substantial
amount of literature related to it. (Boytchev, 2013).
Main characteristics:
Educational (ages 513).
The majority of versions use text-code.
The first activities proposed were problem-solving oriented, although there was
some space for creativity. This will vary with versions.
Uses a drawing area where you can move a pointer called a Turtle.
Main academic fields are basic algorithmics and 2D3D geometry depending on
the version.
In general there were no debuggers, but a step-by-step execution was possible
in many versions, which helped locate errors. Also syntax errors are difficult to
correct.

2.2. C++
Designed by Bjarne Stroustrup in 1983, C++ is a professional computer language utilized
heavily in many academic and professional circles. It is a compiled language, allowing
the user to be able to select a programming environment. Its standard library makes it
easier to use, as compared to its predecessor C (Stroustrup, 2007). It is important to note
that in this category that there are very different approaches depending on the paradigms
used (Duke etal., 2000), but we will not take them into consideration for the current
analysis and will common ground.
Main characteristics:
Professional (ages 12+)
C++ uses formal code.
The language accepts both problem-solving activities and project-oriented
learning.
No drawingarea. General interface uses a console to write and read (input/output). This can be extended to use of files.
Main academic fields are advanced algorithms, data structures, and numerical
problems. Uses of classes helps teach system design.
Depending on the Interface there is a good debugger, but syntax errors are hard
to read.

2.3. Scratch
Scratch was created in 2005 by Lifelong Kindergarten research group at Massachusetts
Institute of Technology Media Lab led by Mitchel Resnick. Although you can trace some
of its origins to Logo, its different approach to teaching computer science places it in a
different category (Resnick etal., 2009).

eSeeCode: Creating a Computer Language from Teaching Experiences

Main characteristics:
Educational (ages 816).
It uses visual block based programming.
The language is more focused on project-oriented programming.
There is a drawing area used to place objects and move them around.
Main academic fields cover basic algorithm, software design.
Due to the visual programming interface with blocks, it is impossible to get syntax
errors. There is no debugger.

2.4. Lightbot
There is an educational movement promoted by code.org to reach children in different
regions of the world and give them tutorials to learn how to code. This movement started
as the Hour of code and has had a big impact all around the world. Almost 200,000
events were carried out in more than 140 countries. (Code.org, 20132016)
Many schools around the world use this material as an introductory material for
Computer Science. Among the different tutorials that you can find, we selected one that
had a large acceptance rate in the teacher community in Spain Lightbot.
Lightbot is a puzzle-based game where you need to light some squares on a grid. It
was created in 2008 by Danny Yaroslavski, but it was with the hour of code that it became popular. (Gouws etal., 2014)
Main characteristics:
Educational (ages 48 and 9+).
It uses visual block based programming.
The language is focused only on puzzle solving.
It has nice animations of a robot moving around.
Main academic fields cover basic algorithms (no variables).
Impossible to get syntax errors, the execution can be considered step-by-step.

3. Developing a Curriculum
It is clear that these languages are difficult to compare to one another because of their
fundamental differences. To be able to do so we will analyse its uses in the classroom
and their main drawbacks if used alone. Later we will study the combination of one or
more language.
When considering the development of a curriculum we have to take into account
many factors, but mainly the maturity of the students (their age) and the amount of time
they will spend engaging with that curriculum. In our case we will consider students
from primary secondary schools, and a relatively long length of time of engagement
(34 years). Although some consider this length insufficient (Winslow, 1996), it is a
valid starting point to achieve competence in programming. Some main objectives can

J. Alemany Flos, J. Vilella Vilahur

be found in some studies (Duncan and Bell, 2015) and in some publications like the
Computing Progression Pathways (Dorling, 2014).

3.1. Teaching with Only One Language


Using the code.org tutorials in the classroom may seem like a good idea because of the
students high level of initial engagement; however, over time this strategy can backfire
if it is assigned for too long as the teacher has limited control over the content (s/he cannot put his own problems), and the tutorials are short and very specific.
One of the programs strong points is that the students get positive feedback and do
not feel frustrated when they fail. This is probably due to the fact that they view Lightbot
and other tutorials in code.org as a game, instead of a class problem.
If we look at the drawbacks from Lightbot we can see that the number of commands
is very limited and do not include variables. For younger children this is good because
the less options you give them the more focused and easy it will be to arrive at solutions.
On the other hand it is not good if the students are mature enough to learn and understand
it quickly. The use of loops is another drawback. To create a loop one must make a procedure that calls upon itself (as in recursion). This makes an infinite type of loop. Although
the students can find it intuitive, they have a difficult time understanding conditionals
and being able to predict this kind of behaviour. Fig. 3 shows the use of loops and functions. We have to keep in mind that although some teachers might use it as a tool to teach
programming, it does not cover some basic algorithmic concepts that are important, and
its programs cannot be generalised. (Lightbot 2016, Gouws etal., 2014 )
Currently in Spain the most popular educational programming language is Scratch,
where it has become quite popular, evidenced by the fact that Barcelona hosted the Connecting Worlds Scratch Conference in 2013. With Scratch, students are engaged and
motivated (Saez-Lopez, 2016), but after many years of use their interest wanes. This is
a big drawback because it generates apathy towards programming and, in some cases,
a dislike for programming altogether. There are also some technical drawbacks. For
example, the lack of text coding makes it difficult to read and write long conditionals
and programs. There are some projects to overcome this difficulty (Harvey and Mnig

Fig. 3. Lightbot usage of recursive procedures instead of loops.

eSeeCode: Creating a Computer Language from Teaching Experiences

2010), but it is not included in the main tool. In addition, the high level language makes
the student miss the opportunity to understand what is behind some of the instructions.
Finally, as it can be seen in Fig. 4, Scratch allows some parallel programming, which
is actually not accurate as it is executed sequentially and depends on the order the procedures were created. This is a problem because the student cannot guess the results of a
given program, which is one of the main objectives when teaching CS. (Dorling, 2014)
For a long time the most popular educational programming language in Spain was Logo.
It was used in the 1980s through early 1990s, but its use faded away in the late 1990s. We
can see this, for example, because it disappeared from the teacher majors in universities.
There was not an immediate substitution by another language, but the government stopped
promoting it as it was not news. This is reflected, for instance, in the use of it when training
teachers at that time. (Simon, 1996) At the onset, students were motivated by this new approach to teaching and learning (Rubinstein, 1974), but today the look of a majority of the
Logo platforms appear outdated and need a visual update. There are two major drawbacks
to Logo. Its theoretical use was for students aged 513, with newer versions this could be
extended until age 15, but text-based coding may bring syntax errors, and students need
some maturity to be able to correct them. If not well attended students would get frustrated
with programs that could not run. At the same time, similarly to Scratch, it has a limited
life span in the student studies due to the apparent lack of practical utility.
The last group of languages to analyse is the professional ones. This are the most
common choice among high school students. The students see the real value of coding and can explore other areas such as physics and mathematics, but because it is not
prepared for the classroom the learning curve is very steep. Winslow describes the five
steps from novice to expert (Winslow, 1996), in small-to-medium classrooms, the steep
learning curve produces a clear and early separation between those who understand the
content (and move through Winslow learning steps) and those who do not and remain as
Novices. Another drawback is that due to the lack of visual assistance (in general) and

Fig. 4. Scratch multiple parallel procedures.

10

J. Alemany Flos, J. Vilella Vilahur

less attractive interface it is more difficult to motivate the students to use it. The syntax
of some functions can also be a problem for some students. For instance, the syntax of
the for loop is more complicated than in other languages, which makes basic algorithms
sometimes hard to teach (Finkel etal., 1994, Robins and Rountree, 2003). Depending
on the programming environment used, the syntax errors are very difficult to read to the
untrained eye, as can be seen in Fig. 5, where only a single character missing produces
20 lines of errors when compiling.
One big advantage is the amount of resources that can be found on the internet, in
particular online judges like Codeforces, Timus, Topcoder, etc. With this sort of information it is really easy to prepare lists of problems for the students to engage.
It is worth pointing out that, in general, all of these languages and platforms are
student focused. There are few tools for the teachers, and this makes using only one
language more difficult. There are some positive exceptions, like the case of Jutge.org.
(Jutge 20082016, Gimnez etal., 2012) This online automated judge has been prepared
as a tool for the classroom and not just for self-learning. Teachers can set up classes,
have their own sets of problems and can view students progress. This kind of platform
contributes to the gamification of learning computer science, by giving achievements,
keeping track of the number of problems solved, etc. When students perceive it as a
game, they become more motivated and less frustrated.

4. Our Proposal: eSeeCode


After the analysis of the pros and cons of the different languages we decided that we
should try to create a language that would eliminate almost all the weaknesses.
The result of our work is eSeeCode both a language and a programming environment.
Main characteristics:
Both visual code and formal code. You can transition from one to another.

Fig. 5. Syntax error in C++. The programming environment is CodeBlocks.

eSeeCode: Creating a Computer Language from Teaching Experiences

11

Both educational and professional language.


It is problem solving oriented.
Main academic areas cover basic and advanced algorithms, 2D geometry (turtle
graphics) and numerical problems.
Has a debugger, and includes simple syntax errors handling.

4.1. Description of eSeeCode


eSeeCodes environment offers four different programming levels: from a pure graphical click-and-run interface to a pure text syntax highlighting editor, with two middle interfaces. We call this levels views, because we want to show the students that code is just
a representation that can have different forms. This can be seen in Fig. 6. This allows for
a smooth progress in programming learning while keeping a common general interface,
instruction set and platform. Time saved in this manner can be spent reinforcing other
important objectives or learning a complementary second language.
The Touch view is our approach to the Puzzle Solving problems and is designed to
work with students of ages 58. The set of instructions is represented by a set of icons
(Fig. 7). The icons at this level have no text to maximize ease of use. These instructions

Fig. 6. Different views of the same code and its result.

Fig. 7. Instruction set of the Touch view.

12

J. Alemany Flos, J. Vilella Vilahur

cover the basic movement of the guide, size of the drawing, colours and general positioning. Each time the student clicks one instruction the environment executes it directly.
The second view created is the Drag view. This view still uses icons as instructions
but the student can move them freely once placed in the coding area. These instructions
accept different arguments and the icons change to match the values of the parameters.
Some examples of this behaviour can be seen in Fig. 8. Notice that the icons also include
a name to help the student read the code. To execute a program the student needs to
click the run button.
The next view is the Build view, which is similar to the Drag view as the blocks can
be displaced around the code area freely. However these blocks dont include icons, just
the name of the instructions and the arguments. The student can read the code fully, but
to create it has to choose among a specific set available. This set is larger than the one
from the drag view and contains a greater variety of instructions. This list of instructions
allows the student to be able to explore eSeeCode by him/herselves, and provides the
student with the familiarization of the names without having to memorize the commands
and the arguments.
The last view is the Code view. In this level students can type their own code.
We created eSeeCode based on JavaScript (although this base is well hidden), so after mastering in the programming in Code view the students can program freely using this well-known programming language. The platform accepts and executes any
JavaScript program allowing for a deeper learning. A side advantage to the use of
JavaScript is the fact that it is not required to be installed to function, as it will work
with any browser.
In the Code view syntax errors are possible, but we try to give short errors that the
student can correct. This can be seen in Fig. 9. The platform also has a debugger to be
used in case the students program does not execute as expected. When running a program, the editor will restyle the code to encourage students to use clean code.
In the context of the low-floor, high-ceiling proposed by Papert (Papert, 1980) and
used by Resnick (Resnick etal., 2009), eSeeCode has a lower-floor (easy-to-use) than
Logo and Scratch, and a much higher ceiling (being able to hold complex programs)
comparable to that of C++. The Touch view could be considered our low-floor while the
Code view our high-ceiling.
Although you can try to create long programs, we have designed eSeeCode to be a
problem-solving tool and have provided it with an optional easy-to-use Input/Output
interface.

Fig. 8. The icons of the Drag view adapt depending on their parameters.

eSeeCode: Creating a Computer Language from Teaching Experiences

13

Fig. 9. Syntax error in eSeeCode.

4.2. Teacher Point of View


Programming languages, platforms, and materials are only oriented towards the students use, obviating that one of the most influential parts on the learning of any process
is the teacher. Providing teacher tools, and configurable platforms is key to an excellent
use in class, given the uniqueness of each environment.
One of the main purposes of creating eSeeCode was also to be able to give the
teacher a set of tools so s/he can create high quality exercises and materials for their
courses. The interface is highly and easily configurable and it can be embedded in any
webpage, allowing the teachers to configure it for each problem if needed. The tools
already implemented are:
A tutorial creation assistant, which creates dynamic tutorials
A problem setter assistant, with which the teacher can restrict the views that can
be used, decide which instructions are allowed (and how many times each can be
used), preload code (hidden or not to the student) so that the student only needs to
complete part of it, etc.
Create step-by-step animations of the execution of programs.
Some of this tools are complemented by a Moodle module that allows the teacher to
collect students problems and to set up specific exercises.

4.3. Experiences with Students


Many experiences have been carried out with students, both in an academic context and
as an extracurricular activity.
eSeeCode has been used as a language to transition from Scratch to C++, and avoid
the difficulties that appear from going from a visual block based language to a textual
based language (Dorling etal., 2015). This experience was done with 12 years old students that had previous knowledge of Computer Science since they had taken some

14

J. Alemany Flos, J. Vilella Vilahur

Scratch courses. This allowed the teachers to teach directly using Code view, but they
allowed the students to go back to the Build view to avoid the empty page difficulty
(Resnick et al., 2009), where the student doesnt know how to start because he is used to
having a set of blocks. With the introduction of eSeeCode the teachers had to review the
basic concepts of variables, conditionals, loops, etc. The methodology that was used was
based on Polya problem-solving principles, where the student should take the following
steps (Polya, 1945):
1. Understanding the problem i.e. Can you explain the problem with different words?
Can you create your own paper and pencil examples?
2. Devising a plan. In our case this is clearly the Algorithm. Some things to consider
when devising a plan are to try to find previous, similar problems.
3. Carrying out the plan. This is the implementation of the algorithm. We propose
the baby steps methodology, where you write the code step-by-step and execute
along to avoid syntax errors, while making sure everything goes accordingly to the
plan.
4. Looking Back. Although no judge system has been created, the student should
analyse if s/he obtained the desired result, going back to previous steps if s/he did
not.
Although this experience is different than the experiment done by Lewis in a study to
compare Scratch vs Logo (Lewis, 2010), a similar survey was created and it was taken
by 59 of the students in the course. The survey consisted of 16 questions each being a
4-level Likert scale.
As it can be seen in Fig. 10 it seems that Scratch is easier to program, but in fact
the total number of students that have a positive feedback (Strongly agree and Agree)

Fig. 10. Students responses to a 4-level likert test about the use of Scratch and eSeeCode in class.

eSeeCode: Creating a Computer Language from Teaching Experiences

15

is larger in the case of eSeeCode. One of the difficulties to analyse this question is the
fact that the problems that the students had to solve in the two languages are different.
What is interesting is that students would recommend in general to use eSeeCode to
teach programming, this might have similar reasons to what Lewis describes (Lewis,
2010), as the students feel more self-secure when typing their own code, and might see
Scratch as something different than programming. This would be interesting to analyze
in a future study.
When asking questions about the difficulties when learning the language, we encounter different opinions depending on the topic. In Fig. 11 we can see this results.
Similar to what happened when asking about writing a program the opinion of the
students is less strong with eSeeCode than with Scratch, although the numbers of positive vs negative are similar. We have to take into account that the view students were
using more is the Code view, which makes it difficult to give a precise analysis of the
situation.

Fig. 11. Student responses to a 4-level likert test about the difficulties when learning with
Scratch and eSeeCode.

16

J. Alemany Flos, J. Vilella Vilahur

What might be interesting is that the students opinion about the difficulties of the
concept of repeat is statistically independent of the language (a Fisher exact test gives
us a p-value of 0.3401 which tells us that the groups are not significantly different) This
can be because the repeat concept is very easy to understand by the students.
Another experience we want to share is our own version of hour of code (Fig. 12)
where students had to make programs to draw some typical optical illusions. Placing
this activity in the context of students having an enjoyable time seemed to motivate
the students to complete the tutorials and to try to draw their own images. Some of the
activities were designed to be more difficult than the level of knowledge the students
possessed and were accompanied with a solution code. The students would read the
code and try to figure out the expected result. Although some students were not able to
complete the activity, most of them enjoyed it. Another experiment we conducted was
to give students the partial code for the program. In this activity we eliminated all the
numbers from the code. The student was required to fill the gaps, until the right image
would appear. Very few students would try numbers at random, the majority would
first try to understand what the code did, and place the right numbers directly.
Three different sets of students tried the platform with this activity: Students that had
never programmed before, students that had been introduced to Scratch and students that
already knew Logo and C++. The difficulties found were similar in each group, concluding that it adapts to the students needs.

Fig. 12. Tutorials from our Hour of Code.

eSeeCode: Creating a Computer Language from Teaching Experiences

17

4.4. Further Work


We have released eSeeCode as an open source project, and as such it is a continuing
development. We believe that further work in the platform should include:
A new and adaptable design to make it feel more modern, and more user-friendly.
Not allowing syntax errors in the Blocks and Build views.
Teacher support material to be able to be used in class by non-programmer teachers.
A formal study of the impact in the long run process and how it can be included
in the regular curriculum. We believe this study should contain reports on Scratch,
C++ and eSeeCode.

5. Conclusions
The time has come for teachers in Spain to take on the responsibility of curriculum
development. This responsibility will come first by understanding the different options
there exist, understanding the previous objectives, the ones we want to have in their
place, and taking on a global vision. Right now one language cannot satisfy all the learning process. It is also valuable for the students to know more than one language, which
would provide the option of overcoming the inherent weaknesses of each one.
eSeeCode tries to provide a new platform to overcome the main weaknesses found,
but we believe it does not need to be a replacement but rather a complement to the learning process. The trials so far show that it is a viable language to take into the classroom,
and that the students show a good overall satisfaction with it.

6. References
Ackovska, N., Erdsn NMeth, ., Stankov, E., Jovanov, M. (2015). Report of the IOI Workshop Creating an
International Informatics Curriculum for Primary and High School Education. Olympiads in Informatics,
9, 205212.
Boytchev, P. (2014). Logo Tree Project. http://www.elica.net/download/papers/LogoTreeProject.pdf
Code.org (2013). http://www.code.org
Dijkstra, E. (1999). Computing Science: achievements and challenges. ACM SIGAPP Applied Computing, 7(2),
29.
Dorling, M. (2014). Computer progression pathways. Computing at Schools.
http://www.computingatschool.org.uk
Dorling, M., White, D. (2015). Scratch: a way to Logo and Python. In: SIGCSE 15: Proceedings of the 46th
ACM Technical Symposium on Computer Science Education.
Duncan, C., Bell, T. (2015). A pilot computer science and programming course for primary schools. In: Proceeding WiPSCE 15 Proceedings of the Workshop in Primary and Secondary Computing Education. 3948.
Duke, R., Salzman, E., Burmeister, J., Poon, J., Murray, L. (2000). Teaching programming to beginners
choosing the language is just the first step. In: ACSE 00: Proceedings of the Australasian conference on
Computing education.
eSeeCode (20152016). http://www.eseecode.com
Finkel, D., Hooker C., Salvidio, S., Sullivan, M., Thomas C. (1994). Teaching C++ to high school students. In:

18

J. Alemany Flos, J. Vilella Vilahur

SIGCSE 94: Proceedings of the twenty-fifth SIGCSE symposium on Computer science education.
FMSLogo (20062016). http://fmslogo.sourceforge.net/
Gimnez, O., Petit, J., Roura, S. (2012). Jutge.org: an educational programming judge. In: Proc. of the 43rd
ACM Technical Symposium on Computer Science Education (SIGCSE-2012). 445450.
Gouws, L.A., Bradshaw, K., Wentworth, P. (2013). Computational thinking in educational activities: an evaluation of the educational game Light-bot. In: ITiCSE 13: Proceedings of the 18th ACM conference on Innovation and technology in computer science education.
Harvey, B., Mnig, J., (2010) Bringing No Ceiling to Scratch: can one language serve kids and computer
scientists? Constructionism 2010, Paris. http://www.eecs.berkeley.edu/~bh/BYOB.pdf
Jutge.org (2012). http://www.jutge.org
Lewis C. (2010). How programming environment shapes perception, learning and goals: logo vs. Scratch. In:
SIGCSE 10: Proceedings of the 41st ACM technical symposium on Computer science education. 346350.
Light-Bot (2016). http://www.lightbot.com
Papert, S. (1980). Mindstorms: Children, Computers and Powerful Ideas. Basic Books. Inc. USA.
Polya, G. (1945). How to solve it. Princeton University Press, USA.
Resnick, M., Maloney, J., Monroy-Hernndez, A., Rusk, A., Eastmond, E., Brennan, K., Millner, A., Rosenbaum, E., Silver, J., Silverman, B., Kafai, Y. (2009). Scratch: programming for all. Communications of the
ACM, 52(11).
Robins, A., Rountree, N. (2003). Learning and teaching programming: a review and discussion. Journal Computer Science Educations, 13(2), 137172.
Rubinstein, R. (1974). Using Logo in teaching. ACM SIGCUE Outlook, 9(SI).
Saez-Lopez, J.M., Roman-Gonzalez, M., Vazquez-Cano, E., (2016). Visual programming languages integrated
across the curriculum in elementary school: a two year case study using Scratch in five schools. Elsevier
computers & Education, 97, 129141.
Scratch (20132016). https://scratch.mit.edu
Simon, J. (1996). Levoluci de lensenyament del llenguatge logo a lescola de mestres Blanquerna 10 anys.
VI Seminari Logo Terrassa, Spain.
Stroustrup, B. (2007). Evolving a language in and for the real world: C++ 19912006. In: HOPL III: Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages. ACM.
Winslow, L. (1996). Programming pedagogy a psychological overview. ACM SIGCSE Bulletin, 28(3).

J. Alemany Flos holds a degree in mathematics and is currently completing a Masters Degree in Advanced Mathematics and Mathematical Engineering. He is a former high school teacher, who now designs
and helps develop programming curricula in schools as a consultant.
He has been involved with the National Informatics Olympiad for the
last eight years, also attending the International Olympiad in Informatics as a team leader and deputy leader since 2010.
J. Vilella Vilahur holds a degree in Computer Science and has been
teaching programming and robotics for the last ten years at Aula Escola
Europea where he also provides the IT support. He has been involved
in several open source projects and has been the lead programmer in
eSeeCode.

Olympiads in Informatics, 2016, Vol. 10, 1937


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.02

19

Wavelet Trees for Competitive Programming


Robinson CASTRO1, Nico LEHMANN1, Jorge PREZ1,2,
Bernardo SUBERCASEAUX1
Department of Computer Science, Universidad de Chile
Beauchef 851, Santiago, Chile
2
Chilean Center for Semantic Web Research
email: {rocastro, nlehmann, jperez, bsuberca}@dcc.uchile.cl
1

Abstract. The wavelet tree is a data structure to succinctly represent sequences of elements over
a fixed but potentially large alphabet. It is a very versatile data structure which exhibits interesting properties even when its compression capabilities are not considered, efficiently supporting
several queries. Although the wavelet tree was proposed more than a decade ago, it has not yet
been widely used by the competitive programming community. This paper tries to fill the gap
by showing how this data structure can be used in classical competitive programming problems,
discussing some implementation details, and presenting a performance analysis focused in a
competitive programming setting.
Key words: wavelet tree, data structures, competitive programming, quantile query, range query.

1. Introduction
Let = (1 ) be a sequence of integers and consider the following query over .
Query 1. Given a pair of indices ( ) and a positive integer , compute the value of the
-th smallest element in the sequence ( +1 ).
Notice that Query 1 essentially asks for the value of the element that would occupy
the -th position when we sort the sequence ( +1 ). For example, for the sequence = (3 7 5 2 3 2 9 3 5) and the query having ( ) = (3 7) and = 4,
the answer would be 5, as if we order sequence (3 4 5 6 7) = (5 2 3 2 9) we
would obtain (2 2 3 5 9) and the fourth element in this sequence is 5. Consider now
the following update query.
Query 2. Given an index , swap the elements at positions and + 1.
That is, if = (3 7 5 2 3 2 9 3 5) and we apply Query 2 with index 5, we
would obtain the sequence 0 = (3 7 5 2 2 3 9 3 5).
Consider now a competitive programming setting in which an initial sequence of
6
10 elements with integer values in the range [ 109 109] is given as input. Assume that

20

R. Castro et al.

a sequence of 105 queries, each query of either type 1 or type 2, is also given as input.
The task is to report the answer of all the queries of type 1 considering the applications
of all the update queries, every query in the same order in which they appear in the
input. The wavelet tree (Grossi, 2015) is a data structure that can be used to trivially
solve this task within typical time and memory limits encountered in programming
competitions.
The wavelet tree was initially proposed to succinctly represent sequences while still
being able to answer several different queries over this succinct representation (Grossi
etal., 2003; Navarro, 2014; Grossi, 2015). Even when its compression capabilities are
not considered, the wavelet tree is a very versatile data structure. One of the main features is that it can handle sequences of elements over a fixed but potentially large alphabet; after an initial preprocessing, the most typical queries (as Query 1 above) can be
answered in time (log), where is the size of the underlying alphabet. The preprocessing phase usually constructs a structure of size ( log) for an input sequence
of elements, where is a factor that will depend on what additional data structures
we use over the classical wavelet tree construction when solving a specific task.
Although it was proposed more than a decade ago (Grossi etal., 2003), the wavelet tree has not yet been widely used by the competitive programming community.
We conducted a social experiment publishing a slightly modified version of Query 1
in a well known Online-Judge system. We received several submissions from experienced competitive programmers but none of them used a wavelet tree implementation
to solve the task. This paper tries to fill the gap by showing how this structure can be
used in classical (and no so classical) competitive programming tasks. As we will show,
its good performance to handle big alphabets, the simplicity of its implementation, plus
the fact that it can be smoothly composed with other typical data structures used in
competitive programming, give the wavelet tree a considerable advantage over other
structures.
Navarro (2014) presents an excellent survey of this data structure showing the most
important practical and theoretical results in the literature plus applications in a myriad
of cases, well beyond the one discussed in this paper. In contrast to Navarros survey,
our focus is less on the properties of the structure in general, and more on its practical
applications, some adaptations, and also implementation targeting specifically the issues
encountered in programming competitions. Nevertheless, we urge the reader wanting to
master wavelet trees to carefully read the work by Navarro (2014).

2. The Wavelet Tree


The wavelet tree (Grossi, 2015) is a data structure that recursively partitions a sequence
into a tree-shaped structure according to the values that contains. In this tree, every
node is associated to a subsequence of . To construct the tree we begin from the root,
which is associated to the complete sequence . Then, in every node, if there are two
or more distinct values in its corresponding sequence, the set of values is split into two
non-empty sets, and ; all the elements of the sequence whose values belong to

Wavelet Trees for Competitive Programming

21

form the left-child subsequence; all the elements whose values belong to form the
right-child subsequence. The process continues recursively until a leaf is reached; a leaf
corresponds to a subsequence in which all elements have the same value, and thus no
partition can be performed.
Fig. 1 shows a wavelet tree constructed from the sequence
= (3 3 9 1 2 1 7 6 4 8 9 4 3 7 5 9 2 7 3 5 1 3)
We split values in the first level into sets = f1 4g and = f5 9g.
Thus the left-child of is associated to 0 = (3 3 1 2 1 4 4 3 2 3 1 3) If we
continue with the process from this node, we can split the values into 0 = f1 2g and
0 = f3 4g. In this case we obtain as right child a node associated with the sequence
00 = (3 3 4 4 3 3 3). Continuing from 00, if we split the values again (into sets
f3g and f4g), we obtain the subsequence (3 3 3 3 3) as left child and (4 4) as right
child, and the process stops.
For simplicity in the exposition, given a wavelet tree we will usually talk about
nodes in to denote, interchangeably, the actual nodes that form the tree and the subsequences associated to those nodes. Given a node in , we denote by Left() its
left-child and by Right() its right-child in . The alphabet of the tree is the set of
different values that its root contains. We usually assume that the alphabet of a tree is a
set = f1 2 g. Without loss of generality, and in order to simplify the partition
process, we will assume that every node in has an associated value m() such that
Left() contains the subsequence of composed of all elements of with values
m(), and Right() the subsequence of composed of all elements with values
m(). (In Fig. 1 the value m() is depicted under every node.) We can also associate to every node in , two values l() and r(), such that corresponds to
the subsequence of the root of containing all the elements whose values are in the
range [l() r()]. Notice that a wavelet tree with alphabet f1 g has exactly
leaves. Moreover, if the construction is done splitting the alphabet into halves in every
node, the depth of the wavelet tree is (log).

Fig. 1. Wavelet tree for the sequence = (3 3 9 1 2 1 7 6 4 8 9 4 3 7 5 9 2


7 3 5 1 3). Solid lines illustrate the execution of rank3( 14). Dashed lines show the
execution of quantile6( 7 16).

22

R. Castro et al.

As we will see in Section 4, when implementing a wavelet tree the complete information of the elements stored in each subsequence of the tree is not actually necessary.
But before giving any details on how to efficiently implement the wavelet tree, we use
the abstract description above to show the most important operations over this data
structure.

Traversing the Wavelet Tree


The most important abstract operation to traverse the wavelet tree is to map an index in
a node into the corresponding indexes in its left and right children. As an example, let
be the root node of wavelet tree in Fig. 1, and 0 = Left(). Index 14 in (marked
in the figure with a solid line) is mapped to index 8 in 0 (also marked in the figure with
a solid line). That is, the portion of sequence from index 1 to index 14 that is mapped
to its left child, corresponds to the portion of sequence 0 from index 1 to 8. On the other
hand, index 14 in root sequence is mapped to index 6 in Right().
We encapsulate the operations described above into two abstract functions,
mapLeft( ) and mapRight( ), for an arbitrary non-leaf node of . In Fig.1,
if is the root, 0 = Left() and 00 = Right(0), then we have mapLeft(
14) = 8, mapRight(0 8) = 5 and mapLeft(00 5) = 3 (all indexes marked
with solid lines in the figure). Function mapLeft( ) is essentially counting how
many elements of until index are mapped to the left-child partition of . Similarly
mapRight( ) counts how many elements of until index are mapped to the rightchild partition of .
As we will describe in Section 4, these two operations can be efficiently implemented
(actually can be done in constant time). But before going into implementation details, we
show how mapLeft and mapRight can be used to answer three different queries by
traversing the wavelet tree, namely, rank, range quantile, and range counting.

2.1. Rank
The rank is an operation performed over a sequence that counts the occurrences of
value until an index of . It is usually denoted by rank( ). That is, if = (1
) then
rank( ) = jf 2 f1 g j = gj
So for example, in sequence in Fig. 1 we have that rank3( 14) = 3.
Assume that is a wavelet tree for , then rank( ) can be easily computed with
the following strategy. If m() then we know that all occurrences of in appear
in the sequence Left(), and thus rank( ) = rank(Left() mapLeft( )).
Similarly, if m() then rank( ) = rank(Right() mapRight( )). We

Wavelet Trees for Competitive Programming

23

repeat this process until we reach a leaf node; if we reach a leaf with this process, we
know that rank( ) = .
In Fig. 1 the execution of rank3( 14) is depicted with solid lines. We map index
14 down the tree using either mapLeft or mapRight depending on the m value
of every node in the path. We first map 14 to 8 (to the left), then 8 to 5 (to the right) and
finally 5 to 3 (to the left), reaching a leaf node. Thus, the answer to rank3( 14) is 3.
Rank is computed by performing (log) calls to (either) mapLeft or mapRight,
thus the time complexity is ( log) where is the time needed to compute the
map functions. Also notice that a rank operation that counts the occurrences of between indexes and can be computed by rank( ) rank( 1), and thus the
time complexity is also ( log).

2.2. Range Quantile

The range quantile operation is essentially Query 1 described in the introduction: given a
sequence = (1 ), quantile( ) is the value of the -th smallest element
in the sequence ( +1 ). For instance in Fig. 1 for the root sequence we have
that quantile6( 7 16) = 7 It was shown by Gagie etal. (2009) that wavelet trees
can efficiently solve this query.
To describe how the wavelet tree can solve quantile queries, lets begin with a simpler
version. Assume that = 1 and thus, we want to find the -th smallest element among
the first elements in . Then having a wavelet tree for , quantile( 1 ) can
be easily computed as follows. Let = mapLeft( ). Recall that mapLeft( )
counts how many elements of until index are mapped to the left-child of . Thus if
then we know for sure that the element that we are searching for is in the left subtree,
and can be computed as
quantile(Left() 1 mapLeft( ))
On the other hand, if then the element that we are searching for is in the right
subtree, but it will no longer be the -th smallest in Right() but the ( )-th smallest and thus can be computed as
quantile( )(Right() 1 mapRight( ))
This process can be repeated until a leaf node is reached, in which case the answer is
the (single) value stored in that leaf.
When answering quantile( ) the strategy above generalizes as follows. We
first compute = mapLeft( ) mapLeft( 1). Notice that is the number of
elements of from index to index (both inclusive) that are mapped to the left. Thus,
if then the element we are searching for is in the leftchild of between the indexes
mapLeft( 1) + 1 and mapLeft( ), and thus the answer is

24

R. Castro et al.

quantile(Left() mapLeft( 1) + 1 mapLeft( ))


If then the desired element is in the right and can be computed as
quantile( )(Right() mapLeft( 1) + 1 mapLeft( ))
As before, the process is repeated until a leaf node is reached, in which case the answer is the value stored in that leaf. In Fig. 1 the complete execution of quantile6(
7 16) is depicted with dashed boxes in every visited node.
As for the case of the rank operation, quantile can be computed in time ( log)
where is the time needed to compute the map functions.

2.3. Range Counting


The range counting query range[]( ) counts the number of elements with values
between and in positions from index to index . That is, if = (1 ) then
range[]( ) = jf 2 f g j gj
A sequence of size can be understood as the representation of a grid with points
such that no two points share the same row. A general set of points can be mapped to
such a grid by storing real coordinates somewhere and breaking ties somehow. For this
representation the range counting query corresponds to count the number of points in a
given subrectangle (Navarro, 2014).
To answer a range counting query over a wavelet tree we can use the following recursive strategy. Consider the interval [l() r()] of possible elements of a sequence
. If [l() r()] does not intersect [ ], then no element of the sequence is in [
] and the answer is 0. Another case occurs when [l() r()] is totally contained in
[ ]; in this case all the elements of the sequence between and are counted, so the
answer is j[ ]j = +1.
The last case (the recursive one) is when [l() r()] intersects [ ] (but is not
completely contained in [ ]); in that case the answer is the sum of the range counting
query evaluated in both children. The queries for children are called with the same [
] as in the parents call, but the indexes and are replaced by the mappings of these
indexes. That is, the answer is
range[](Left() mapLeft( ) mapLeft( )) +

range[](Right() mapRight( ) mapRight( ))

Note that if range is called on a leaf node , then l() = r() = , so the interval is either completely contained (if 2 [ ]) or completely outside (if 62 [ ]).
Both cases are already considered.

Wavelet Trees for Competitive Programming

25

It is not difficult to show that for a range counting query, we have to make at most
(log) recursive calls (Gagie et al. (2012) show detailed proof), and thus the time
complexity is, as for rank and quantile, ( log) where is the time needed to
compute the map functions.

3. Simple Update Queries


We now discuss some simple update queries over wavelet trees. The idea is to shed light
on the versatility of the structure to support less classical operations. We looked for
inspiration in typical operations found in competitive programming problems to design
update queries that preserve the global structure of the wavelet tree. We only describe
the high level idea on how these queries can be adopted by the wavelet tree, and we later
(in Section 4) discuss on how to efficiently implement them.

3.1. Swapping Contiguous Positions


Consider Query 2 in the introduction denoted by swap( ). That is, a call to swap( )
changes = (1 ) into a sequence (1 +1 ).
The operation swap( ) can be easily supported by the wavelet tree as follows.
Assume first that m(). Then we have two cases depending on the value of +1.
If +1 m(), we know that is mapped to the left subtree while +1 is mapped
to the right subtree. This means that swapping these two elements does not modify any
of the nodes of the tree that are descendants of . In order to modify , besides actually swapping the elements, we should update mapLeft( ) and mapRight( );
mapLeft( ) should be decremented by 1 and mapRight( ) should be incremented by 1 as the new element in position is now mapped to the right subtree. Notice
that these are the only two updates that need to be done to the map functions.
The other case is if +1 m(). Notice that both and +1 are mapped to
Left(), and moreover, they are mapped to contiguous positions in that sequence.
In this case, no update should be done to mapLeft( ) or mapRight( ). Thus,
besides actually swapping the elements in , we should only recursively perform the
operation swap(Left() mapLeft( )) The case in which m() is symmetrical. The complete process is repeated until a leaf node is reached, in which case
nothing should be done.
To perform the swap in the worst case we would need to traverse from top to bottom
of the wavelet tree. Moreover, notice that the map functions mapLeft and mapRight
are updated in at most one node. Thus the complexity of the process is ( log +
) where is the time needed to update mapLeft and mapRight, and is the time
needed to compute the map functions.

26

R. Castro et al.

3.2. Toggling Elements


Assume that every element in a sequence has two possible states, active or inactive,
and that an operation toggle( ) is used to change the state of element from active
to inactive, or from inactive to active depending on its current state. Given this setting,
we want to support all the queries mentioned in Section 2, but only considering active
elements. For example, assume that = (1 2 1 3 1 4) and only the non 1 elements
are active. Then a query quantile2( 1 6) would be 3.
A simple augmentation of the wavelet tree can be used to support this update. Besides
mapLeft and mapRight, we use two new mapping/counting functions activeLeft
and activeRight. For a node and an index , activeLeft( ) is the number
of active elements until index that are mapped to the left child of , and similarly
activeRight( ) is the number of active elements mapped to the right child. Besides this we can also have a count function for the leaves of the tree, activeLeaf(
), that counts the number of active elements in a leaf until position . We next show
how these new mapping functions should be updated when a toggle operation is performed. Then we describe how the queries in Section 2 should be adapted.
Upon an update operation toggle( ) we proceed as follows. If m() then
we should update the values of activeLeft( ) for all adding 1 to
activeLeft( ) if was previously inactive, or substracting 1 in case was previously active. Now, given that is mapped to the left child of , we proceed recursively with toggle(Left() mapLeft( )). If m(), we proceed symmetrically updating activeRight( ) for , and recursively calling
toggle(Right() mapRight( )). We repeat the process until a leaf is reached,
in which case activeLeaf should also be updated (similarly as for activeLeft).
The complexity of the toggle operation is then ((+)log), where is the time
needed to update activeLeft and activeRight in every level (plus activeLeaf
in the last level), and is the time needed to compute the map functions mapLeft
and mapRight.
Consider now the quantile( ) query. Recall that for this query we first computed a value representing the number of elements of from index to index that are
mapped to the left. If we proceeded searching for quantile in the left subtree,
and if we proceeded searching for quantile( ) in the right subtree (mapping
indexes and accordingly in both cases). In order to consider the active/inactive state
of each element, we only need to change how is computed; we need to consider now
how many active elements from index to index are mapped to the left, and thus is
computed as
= activeLeft( 1) activeLeft( )
Then, we proceed exactly as before: if we search for quantile in the left
subtree, otherwise, we search for quantile( ) in the right subtree. Notice that we
always assume that when executing quantile( ) the number of active elements

Wavelet Trees for Competitive Programming

27

between and in is not less than (which can be easily checked using activeLeft
and activeRight).
Queries rank and range[] are even simpler. In the case of rank we only need
to consider the active elements when we reach a leaf; in the last query rank( ) in a
leaf , we just answer activeLeaf( ). In the case of range[]( ), we almost
keep the recursive strategy as before but now when [l() r()] is totally contained
in [ ] we only have to consider the number of active elements between index and
index , which is computed as
(activeLeft( ) + activeRight( ))

(activeLeft( 1) + activeRight( 1))

In the case in which is a leaf, this value is computed as activeLeaf( )


activeLeaf( 1).
The complexity of these new queries is (( + ) log) where is the time
needed to compute the activeLeft and activeRight functions and is the time
needed to compute the map functions.

3.3. Adding and Deleting Elements from the Beginning or End of the Sequence
Consider the operations pushBack( ), popBack(), pushFront( ) and
popFront(), with their typical meaning of adding/deleting elements to/from the beginning or ending of sequence .
First notice that when adding or deleting elements we might be changing the alphabet of the tree. To cop with this, we assume that the underlying alphabet is fixed and
that the tree is constructed initially from a sequence mentioning all values in . Thus,
initially there is a leaf in the tree for every possible value. We also assume that in every
moment there is an active alphabet, which is a subset of , containing the values actually mentioned in the tree. To support this we just allow some sequences in the tree to
be empty; if there is some value of not present in the tree at some point, then the
sequence corresponding to the leaf node associated with is the empty sequence. It is
straightforward to adapt all the previous queries to this new setting.
Consider now pushBack( ) and assume that before the update we have jj =
. Then, besides adding to the end of sequence , we should update (or more precisely, create) mapLeft( +1) and mapRight( +1). If m() then we
let mapLeft( + 1) = mapLeft( ) + 1 and mapRight( + 1) =
mapRight( ), and then perform pushBack(Left() ). If m() then we let
mapLeft( + 1) = mapLeft( ) and mapRight( + 1) = mapRight(
)+1, and then perform pushBack(Right() ). Finally when we reach a leaf node,
we just add to the corresponding sequence.
The popBack() operation is similar. Assume that jj = , then besides deleting
the last element in , we should only delete that element from the corresponding sub-

28

R. Castro et al.

tree. Thus, if m() then we do popBack(Left()), and if m() we do


popBack(Right()). When we reach a leaf node we just delete any element from it.
Notice that in this case no mapLeft or mapRight needed to be updated.
The pushFront and popFront are a bit more complicated. When we do
pushFront() we should do a complete remapping: if m() then for every 2
f1 g we should do
mapLeft( + 1) = mapLeft( ) + 1
mapRight( + 1) = mapRight( )
and finally set mapLeft( 1) = 1 and mapRight( 1) = 0 and perform the call
pushFront(Left() ). If m() then we should do
mapLeft( + 1) = mapLeft( )
mapRight( + 1) = mapRight( ) + 1
and finally set mapLeft( 1) = 0 and mapRight( 1) = 1 and perform the call
pushFront(Right() ). When a leaf node is reached we just add at the beginning of the corresponding sequence. The popFront() operation is similar. Let jj =
. If 1 m() then we should update mapLeft ( ) to mapLeft ( +1)
1, and mapRight( ) to mapRight( +1) for all from 1 to 1, and then do
popFront(Left()). Symmetrically if 1 m() then we should update mapLeft(
) to mapLeft( +1), and mapRight( ) to mapRight( +1) 1 for all
from 1 to 1, and then do popFront(Right()). Upon reaching a leaf node, we just
delete the value from the front.
The complexity of all the operations above is ((+) log) where is the
time needed to update mapLeft or mapRight in every level, and is the time needed
to compute the map functions. Just notice that for the cases of the pushFront and popFront we have to update several values of mapLeft and mapRight per level.

4. Implementation
In this section we explain how to build a wavelet tree and how to construct the auxiliary
structures to support the mapping operations efficiently. Based on this construction we
also discuss how to implement queries explained in the previous section. Additionally,
we present an implementation strategy alternative to the direct pointer based one. We
implemented both approaches in C++ and the code is available in github1.

https://github.com/nilehmann/wavelet-tree

Wavelet Trees for Competitive Programming

29

4.1. Construction
A wavelet tree implementation represents an array [0 1] of integers in the interval
[0 1]. Our construction is based on a node structure and pointers between those
nodes. Every node will be identified by two elements and (which essentially
correspond to l() and r() in Section 2), and an associated sequence which is
the subsequence of formed by selecting elements in the range [ ]. As we will see,
values and and the sequence do not need to be explicitly stored and can be
computed when traversing the tree if needed.
The construction of a wavelet tree starts creating the root node associated to the
original array and the interval [0 1]. We then proceed recursively as follows. In
each node we found the middle of the interval = (+)2 (which corresponds
to the value m() described in Section 2). We create two new nodes and as leftchild and right-child of , respectively. Then, we perform a stable partition of the array
into two arrays and , such that contains all values less than or equal to
and those greater than . The construction continues recursively for the left
node with the array and the interval [], and for the right node with and
the interval [+1 ]. The base case is reached when the interval represented by the
node contains only one element, i.e., = . It is not necessary to store arrays corresponding to each node . They are only materialized at building time to construct the
auxiliary structures to support the mapping operations required to traverse the tree as
described below.
As previously discussed, the fundamental operations mapLeft and mapRight correspond to count how many symbols until position belong to the left and right node
respectively. To support these operations, when building a node we precompute for
every position how many elements in the array belong to the right node they are
greater than and store the results in an array . We could store a similar array 0
to store how many elements belong to the left node, but it is easy to note that values of
both arrays are related as follows: 0 [] = [] + 1.
To understand how is computed, it turns out useful to associate a bitvector
that marks with 0s elements less than or equal to and with 1s those greater than .
This bitvector must support the operation of counting how many bits are set to 1 until a
position , which is commonly referred as a rank operation. Our array is computed on
build time as the partial sum of by the recurrence [0] = [0] [] = [ 1]
+[], thus supporting the rank operation in constant time. The compression characteristics of the wavelet tree arise mainly because it is possible to represent these bitvectors
succinctly while maintaining constant-time rank queries (Clark, 1998; Okanohara and
Sadakane, 2007; Raman etal., 2002). However, in a competitive programming setting
memory constraints are less restrictive and our representation shows off to be sufficient.
In case the memory is an issue, a practical and succinct implementation is presented by
Gonzlez etal. (2005).

30

R. Castro et al.

4.2. Implementing Queries and Updates


We now briey discuss how every operation in Section 2 can be efficiently implemented.
mapLeft and mapRight. These two operations can be easily implemented with the array
; in a node the number of elements until position that go to the left is [] +
1. Since we are indexing from 0, position is mapped to the left to position [].
Analogously, a position is mapped to the right to position [] 1. Notice that both
mapping functions can thus be computed in constant time, which implies that rank,
quantile and range operations can be implemented in (log) time.
swap. The swap operation first map the position down the tree until we reach a node
where the update needs to be performed. At this point the (virtual) bitvector is such
that [] 6= [+1]. Swapping both bits can only change the count of 1s until position , and thus, only [] should be updated. If [] = 0 we do [] = []+1, and
if [] = 1 we do [] = [] 1. This shows that the map functions can be updated
in constant time after a swap operation, which implies that the complexity of swap is
also (log).
toggle. In this case we only need to implement activeLeft, activeRight and activeLeaf. To mark which positions are active we can use any data structure representing sequences of 0s and 1s that efficiently supports partial sums and point updates. For
example we can use a binary indexed tree (BIT) (Fenwick, 1994) which is a standard
data structure used in competitive programming that supports both operations in (log)
time. Thus with a BIT we are adding a logarithmic factor for each query and now rank,
quantile and range operations as well as toggle can be implemented in (log
log). In terms of construction, when using a BIT in every level we are only paying a
constant factor in the size of the wavelet tree.
pushBack and popBack. These operations only modify the array in some nodes.
Pushing an element at the end updates the (virtual) bitvector appending a new 0 or 1
(depending on the comparison between the new element and ), so being a partial
sum of of size only needs a [] = [ 1]+[ 1] update. Popping
an element from the end updates and doing the inverse operation, so if is of
size we only need to delete [ 1] from memory. Both operations can be done in
amortized constant time using a dynamic array, thus the complexity of all queries plus
pushBack and popBack is (log) time.
pushFront and popFront. These are similar to pushBack and popBack, but act at the
beginning of the bitvector . To prepend a bit to a bitvector we must prepend its
value to . If the value of is equal to 1 we must also increment by 1 every value in
. Because it is too slow to update every position of , we define a counter that
starts at 0 and is incremented by 1 every time a bit equal to 1 is prepended. We then just
prepend to , in which case the real count of ones until position is obtained
by []+. Popping an element is as easy as deleting the first element of from

Wavelet Trees for Competitive Programming

31

memory and decrementing by 1 if the value of [0]+ was equal to 1. If we want


to mix front and back operations, we could use a structure such as a dequeue (Knuth,
1997), which allows amortized constant time insertions at the beginning and end of an
array while maintaining constant random access time. Thus the complexity of all queries
is still (log) time.

4.3. Big Alphabets and the Wavelet Matrix


In a competitive programming setting the size of the array will depend on time restrictions, but typically it will not exceed 106. However the number of possible values that
can store could be without any problems around 109. Thus the number of values actually
appearing in is much smaller than the range of possible values. For this reason one
usually have to map the values that appear in the sequence to a range [0 1]. Commonly, this will require a fairly fast operation to translate from one alphabet to the other
with a typical implementation using, for example, a binary search tree or a sorted array
combined with binary search.
To avoid having this map operation, the wavelet tree could be constructed directly
over the range of all possible values allowing the subsequences of some nodes to be empty. A naive pointer-based construction will require () words which might be excessive
for = 109. Because many nodes will represent empty subsequences, one can save some
space explicitly tracking when some subsequences become empty in the tree.
There is an alternative implementation of the wavelet tree called wavelet matrix
(Claude etal., 2015) that was specifically proposed in the literature to account for big
alphabets. Given an alphabet its size can be extended to match the next power of two,
yielding a complete binary tree for the wavelet tree representation. For each level,
we could then concatenate the bitvectors of each node in that level and represent the
structure with a single bitvector by level. The border between each node is lost, but it
can be computed on the fly when traversing. This means extra queries yielding worse
performance. Instead, the wavelet matrix breaks the restriction that in each level siblings must be represented in contiguous positions in the bitvector. When partitioning
a node at some level the wavelet matrix sends all zeroes to the left section of level
+1 and all ones to the right. The left and the right child of some node at level do
not occupy contiguous positions in the bitvector at level +1, but the left (resp. right)
child is represented in contiguous positions in the left (resp. right) section of the level
+1. Additionally, a value is maintained at each level to mark how many elements
were mapped to the left.
With this structure the traversing operations can be directly implemented by performing rank operations on bitvectors at each level. Specifically, instead of maintaining
an array for every node, we maintain an array for each level. Array store the
cumulative number of 1s in level . Then, a position at level is mapped to the left
to position [] at level +1. The same position is mapped to the right to position
+[] 1.

32

R. Castro et al.

The wavelet matrix has the advantage of being implementable using only (log)
extra words of memory instead of the () used to store the tree structure in the pointer
based alternative while maintaining fast operations. This (log) words are insignificant even for = 109, which means that the structure could be constructed directly over
the original alphabet. On the other hand the wavelet matrix is somehow less adaptable,
because it does not support directly the pop and push updates. However, it can support
swap and toggle in a similar way as the one described for the wavelet tree.

5. Wavelet Trees in Current Competitive Programming


We conducted a social experiment uploading 3 different problems to the Sphere Online
Judge (SPOJ)2. All the problems can be solved with the techniques shown in the previous sections. We analyze the solutions to these problems submitted by SPOJ users. Our
analysis reveal two main conclusions: (1) experienced programmers do not consider the
use of wavelet trees, even in the case that its application is straightforward, and (2) for
the most complex cases when they succeed, they use fairly involved techniques producing solutions that are dangerously close to time and memory limits. We have found,
however, some incipient references of wavelet trees in the competitive programming
community3, as well as more detailed explanations in Japanese4, which obviously establish an idiomatic barrier for many programmers.
We identify the three mentioned problems as ILKQ1, ILKQ2 and ILKQ3 and they
are described as follows.
ILKQ1 considers a slightly modified version of the quantile query. The size of the initial
sequences is 105, the range of possible integer values in the sequence is [109 109], and
the number of queries is 105. The time limit is 1s.
Link: http://www.spoj.com/problems/ILKQUERY
ILKQ2 considers rank queries plus toggling the state of arbitrary elements. The size of
the initial sequence is 105, the range of possible values is [109 109], and the number of
rank plus toggle queries is 105. The time limit is 0.4s.
Link: http://www.spoj.com/problems/ILKQUERY2
ILKQ3 considers the quantile query of ILKQ1 plus swaps of arbitrary contiguous positions. The size of the initial sequences is 106, the range of possible values is [109 109],
and the number of quantile plus swap queries is 105. The time limit is 1s.
Link: http://www.spoj.com/problems/ILKQUERYIII/
Notice that ILKQ3 although involves the same query as ILKQ1, it is considerable
harder as it can mix updates (in the form of swaps) and the input sequence can be 10
times bigger than for ILKQ1. Table 1 shows an analysis of the submissions received5.
2

http://www.spoj.com/
http://codeforces.com/blog/entry/17787
4
http://d.hatena.ne.jp/sune2/20131216/1387197255
5
This data considers only until late March 2016.
3

33

Wavelet Trees for Competitive Programming


Table 1
General submission statistics
Submitted
ILKQ1
ILKQ2
ILKQ3

49
32
35

Accepted
9
6
2

Non-accepted
WA
TLE

RTE

19
15
12

3
3
6

18
8
15

5.1. Analysis of Users Submitting Solutions


We received submissions from several type of users, several of them can be considered
as experienced programmers. From them, even expert coders (rank 100 or better on
SPOJ) got lot of Wrong Answers (WA) or Time Limit Exceeded (TLE) verdicts which
shows the intrinsic difficulty of the problems. Considering the three problems, 5 out
of the 10 distinct users who got an Accepted (AC) veredict have rank of 60 or better
on SPOJ, and 8 are well-known ACM-ICPC World finalists. For problem ILKQ3 we
received only two AC. Both users solved the problem after several WA or TLE verdicts.
For ILKQ1 and ILKQ2 the best ranked submitter was the top 1 user in SPOJ who obtained AC in both problems. For ILKQ3, the best ranked submitter was among the top 5
in SPOJ and obtained only TLE veredicts.

5.2. Analysis of the Submitted Solutions


As we have told before, we received 0 submissions implementing a wavelet tree solution. We now briefly analyze the strategies of the submissions received. For the sake of
the space, we cannot deeply analyze every strategy but we provide some pointers for the
interested reader.
The most common approach for ILKQ1 was sorting queries (as the problem is offline) plus the use of a tree data structure. One of the mainly used in this case was
mergesort tree. In a mergesort tree, nodes represent sequences of contiguous elements
of the original array and contains a sorted version of those sequences. Leaves represent
one element of the array, and the tree is built recursively by merging pairs of nodes
starting from the leaves. The construction can be done in ( log) time and space.
Quantile queries can be answered by identifying the, at most (log), nodes that define
a query range, and then doing two (nested) binary searches, one for counting elements
less than or equal than a value , and the second over to find the -th minimum element. The total strategy gives (log3 ) time which can be optimized up to (log2 )
using fractional cascading. This was enough given the time constraints.

34

R. Castro et al.

For ILKQ2 and ILKQ3 sorting of queries or any offline approach is not directly
useful as queries are mixed with updates. For ILKQ2 we received some submissions
implementing a square root decomposition strategy, and run extremely close to the time
limit. The most successful strategy in both problems was the use of ideas coming from
persistent data structures, in particular persistent segment trees6. As in any persistent
structure, the main idea is to efficiently store different states of it. Exploiting the fact that
consecutive states do not differ in more than (log ) nodes, it is possible to keep different segment trees in ( log ) space. Persistent segment trees can be used to answer
quantile queries but need some more work to adapt them for updates like swaps as in
ILKQ3. The two correct solutions that we received for ILKQ3 make use of this structure.
Its relevant to notice that given the input size and the updates, implementing a persistent
segment tree for this problem can use a considerable amount of memory. In particular,
one of the AC submissions used 500MB and the other 980MB. Our wavelet tree solution
uses only 4MB of memory.

6. Performance Tests
Existing experimental analyses about wavelet trees focus mostly on compression characteristics (Claude et al., 2015). Moreover, they do not consider the time required to
build the structure because from the compression point of view the preprocessing time is
not the most relevant parameter. Thus, we conducted a series of experiments focusing on
a competitive-programming setting where the building time is important and restrictions
on the input are driven by typical tight time constraints. The idea is to shed some light on
how far the input size can be pushed. We expect these results to be useful for competitors
as well as for problem setters.
We performed experimental tests for our wavelet tree and wavelet matrix implementations comparing construction time and the performance of rank, quantile and range
counting queries. We consider only alphabets of size less than the size of the sequence.
To analyze the impact of the alphabet size, we performed tests over sequences of different profiles. A profile is characterized by the ratio between the size of the alphabet
and the size of the sequence. For example, a sequence of size 103 and profile 05 has an
alphabet of size 500.
Measurements. To measure construction time we generated random sequences of increasing size for different profiles. For each size and profile we generated 1,000 sequences and we report the average time. For queries rank, quantile and range counting,
we generated 100,000 queries uniformly distributed and averaged their execution time.
The machine used is an Intel Core i7-2600K running at 3.40GHz with 8GB of RAM
memory. The operating system is Arch-Linux running kernel 4.4.4. All our code are
single-threaded and implemented in C++. The compiler used is gcc version 5.3.0, with
optimization flag -O2 as customary in many programming contests.
6

bit.ly/persistent-segment-tree

35

Wavelet Trees for Competitive Programming

Results. No much variance was found in the performance between different profiles, but
as may be expected sequences of profile 1 i.e., permutations reported higher time in
construction and queries. Thus, we focus on the analysis of permutations to test performance on the most stressing setting. For the range of input tested we did not observe big
differences between the wavelet tree and the wavelet matrix, both for construction and
query time. Though there are little differences, they can be attributed to tiny implementation decision and not to the implementation strategy itself.
Regarding the size of the input (Fig. 2), construction time stays within the order
of 250 milliseconds for sequences of size less than or equal to 106, but scales up to
2 seconds for sequences of size 107, which can be prohibitive for typical time constraints. For the case of queries rank, quantile and range counting we report in Fig. 3
the number of queries that can be performed in 1 second for different sizes of the input
sequence. For rank and quantile, around 106 queries can be performed in 1 second for
an input of size 106. In contrast for range counting, only 105 queries can be performed
in the same setting (Fig. 3).
It would be interesting as future work to perform a deep comparison between the
wavelet tree and competing structures for similar purposes such as mergesort trees
and persistent segment trees, testing time and memory usage. From our simple analysis in the previous section one can infer that wavelet trees at least scales better in
terms of memory usage, but more experimentation should be done to draw stronger
conclusions.

 





 











 

 

Fig. 2. Construction time in milliseconds.






























  





   



 

 
















Fig. 3. Number of queries that can be performed in one second.


 



36

R. Castro et al.

7. Concluding Remarks
Problems involving advanced data structures are appearing increasingly often in worldwide programming competitions. In this scenario, competitive programmers often prefer
versatile structures that can be used for a wide range of problems without making a lot of
changes. Structures such as binary indexed trees or (persistent) segment trees, to name
a few, conform part of the lower bound for competitors, and must be in the toolbox of
any programmer. The wavelet tree has proven to be a really versatile structure but, as
we have evidenced, not widely used at the moment. However, we have noted that some
programmers have already perceived the virtues of the wavelet tree. We believe that the
wavelet tree, being quite easy to implement, and having such amount of applications, is
probably becoming a structure that every competitive programmer should learn. With
this paper we try to fill the gap and make wavelet trees widely available for the competitive programming community.

Acknowledgments
J. Prez is supported by the Millennium Nucleus Center for Semantic Web Research,
Grant NC120004, and Fondecyt grant 1140790.

References
Clark, D. (1998). Compact Pat Trees. PhD thesis, University of Waterloo.
Claude, F., Navarro, G., Ordez, A. (2015). The wavelet matrix: an efficient wavelet tree for large alphabets.
Inf. Syst., 47, 1532.
Fenwick, P. M. (1994). A new data structure for cumulative frequency tables. Software: Practice and Experience, 24(3), 327336.
Gagie, T., Navarro, G., and Puglisi, S.J. (2012). New algorithms on wavelet trees and applications to information retrieval. Theor. Comput. Sci., 426, 2541.
Gagie, T., Puglisi, S.J., Turpin, A. (2009). Range quantile queries: another virtue of wavelet trees. In: SPIRE.
16.
Gonzlez, R., Grabowski, S., Mkinen, V., Navarro, G. (2005). Practical implementation of rank and select
queries. In: WEA. 2738.
Grossi, R. (2015). Wavelet trees. In: Encyclopedia of Algorithms. Springer.
Grossi, R., Gupta, A., Vitter, J.S. (2003). High-order entropy-compressed text indexes. In: SODA03. 841850.
Knuth, D. (1997). The Art of Computer Programming, Volume 1: Fundamental Algorithms. Third Edition.
Addison-Wesley. 238243.
Navarro, G. (2014). Wavelet trees for all. J. Discrete Algorithms, 25, 220.
Okanohara, D., Sadakane, K. (2007). Practical entropy-compressed rank/select dictionary. In: ALENEX. 60
70.
Raman, R., Raman, V., Rao, S. (2002). Succinct indexable dictionaries with applications to encoding k-ary trees
and multisets. In: SODA. 233242.

Wavelet Trees for Competitive Programming

37

R. Castro is a computer engineering student at Department of Computer Science, Universidad de Chile, bronze medalist of IOI2013 in
Brisbane, and problem setter for OCI (Chilean Olympiad in Informatics).

N. Lehmann is masters student in computer science at Department


of Computer Science, Universidad de Chile. His research interests are
semantics, design and implementation of programming languages and
type systems. He is the Scientific Committee Director of OCI (Chilean
Olympiad in Informatics). Deputy Leader at IOI 2014 and 2015. Chilean Judge of ACM ICPC 2014 and 2015.
J. Prez is Associate Professor at the Department of Computer Science, Universidad de Chile, and an Associate Researcher of the Chilean Center for Semantic Web Research. His research interests are database theory, data exchange and integration, graph databases, and the
application of database technologies to the Semantic Web and the Web
of Data. He is one of the directors of OCI (Chilean Olympiad in Informatics), and the Chilean team leader at IOI since 2013.
B. Subercaseaux is an undergraduate student of computer science at
Department of Computer Science, Universidad de Chile, and problem
setter for OCI (Chilean Olympiad in Informatics).

Olympiads in Informatics, 2016, Vol. 10, 3960


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.03

39

Learning Programming through


Games and Contests:
Overview, Characterisation and Discussion
Sbastien COMBFIS1,2, Gytautas BERESNEVIIUS3
Valentina DAGIEN3
Electronics and IT Unit, cole Centrale des Arts et Mtiers (ECAM)
Promenade de lAlma 50, 1200 Woluw-Saint-Lambert, Belgium
2
Computer Science and IT in Education ASBL, Belgium
3
Vilnius University Institute of Mathematics and Informatics
4 Akademijos Street, Vilnius LT-08663, Lithuania
E-mails: s.combefis@ecam.be; gytber@gmail.com; valentina.dagiene@mii.vu.lt
1

Abstract. Learning of programming and, more generally, of computer science concepts is now
reaching the public at large. It is not only reserved for people who studied informatics (computer
science) or programming anymore. Teaching programming to schoolchildren presents many
challenges: the big diversity in ability and aptitude levels; the big amount of different tools; the
time-consuming nature of programming; and of course the difficulty to motivate schoolchildren
to keep them busy with hard work. There are various platforms that offer to learn coding and
programming, in particular game-based platforms, which are more and more popular. These
latter exploits of the gamification process focused on increase in motivation and engagement
of the learners. This paper reviews the main kinds of online platforms to learn programming
and more general computer science concepts, and illustrates the review with concrete platforms
examples.
Keywords: game-based learning, gamification, learning programming, online programming platform, programming contest.

1. Introduction
Informatics (computer science or computing) as a science discipline, and in particular
programming as an important part of that, is gaining a lot of popularity these years in
education. As core subjects in a computer science (CS) major, programming subjects
play an important role in a successful CS education. One of the greatest challenges
faced by most students is the understanding of programming basics, especially for novices or for those who are in their first year of studies. Students develop algorithmic

40

S. Combfis, G. Beresneviius, V. Dagien

thinking or computational thinking at secondary and even at primary school. Using


simple programming languages such as Scratch became accessible to young children
(Maloney etal., 2004).
Games have been used for educational purposes for decades. The popularity of games
has led to the idea of using them in the learning of programming, taking advantage of
the engaging features of games. In a very broad sense, two different approaches are used
when using games or game-like elements in educational contexts: 1) gamification and
2) serious games. The term gamification is commonly defined as the use of game design
elements in non-game contexts (Deterding etal., 2011). Serious games are associated
with a standalone game or platform, as well as indicated as a computer game (Djaout
etal., 2011). In this paper, we are going to use the general term to refer to game-based
learning with main focus on teaching programming.
Game-based learning is concerned with using games not for entertainment, but for
educational purposes. Those who work within the field of gamification focus on identifying the context and conditions that support the integration of digital games within
informal and formal learning environments. Educational scientists have pointed up
several features of games that allow them to be used as learning tools. For example,
games are engaging (Dickey, 2005) and motivating (Prensky, 2003). They also provide
a lot of experiences (Arena and Schwartz, 2013) and an excellent feedback on performances (Shute, 2011). Finally, games support very well the learner centred education
(Gee, 2005).
A contest can be seen as a part of game-based learning. Contests make the teaching
of programming more attractive for students. Furthermore, programming with computer
is one of the appropriate and effective ways to develop problem solving skills and computational thinking. During contests, students have the possibility to compare their abilities and learn from others. There have been many contests in programming throughout
all over the world; most of them focus on algorithmic problem solving.
Many teaching environments already contain game-like elements such as points, instant feedback, and goals. However, there are engaging aspects in games that could be
used in educational settings more widely. In well-designed games, even a failure can be
a reward and triggers positive emotions (Ravaja etal., 2005). There is no off-the-shelf
formula for designing successful games, nor is there one perfect learning environment.
However, by deepening our understanding of the effects of games and game-like environments in educational settings, we can design and support more effective learning
activities, and ultimately improve the learning of computer science.
The move from classical learning platforms to online contests and games can be
explained as a way to ensure the best motivation as possible for their users. The online
platforms can provide tools such as rankings, duels, discussion rooms, etc. to motivate
their users to participate regularly. Finally, research on gamification in all its forms has
proven that educational games improve the engagement of learners if the game is designed properly (Barata etal., 2013; Nah etal., 2014). Online platforms where students
can learn programming are being developed all over the world, ranging from simple direct learning platforms to platforms of games that indirectly teach programming (Combfis and Wautelet, 2014).

Learning Programming through Games and Contests: Overview, ...

41

This paper reviews literature of the last decade on programming education for school
students (high, secondary and primary levels) using games and online platforms that
support games and contests which goal is to teach programming. The literature review
of programming games and an overview of programming learning platforms were structured to accomplish the following three research objectives:
1. To overview the last decade literature on programming education using games.
2. To identify the important online platforms for learning programming through
games and contests.
3. To identify suitable tools for programming novices.
The goal of the paper is twofold: from one side, to provide an overview of the work
that has been done in this area, and from the other side, to discuss the important tools
(online platforms and contests) and to improve programming education. After this introductory part, Section2 makes a short presentation of the understanding of gamification
and overviews the literature on teaching programming using games. Section 3 presents three kinds of online platforms, which allow students to learn programming. Then
Section 4 tours several existing contest platforms. Finally, the last section concludes
the paper with some thoughts about what could be the future evolution of these online
platforms and contests and makes some suggestions for teaching programming by educational games or by other ways.

2. Short Overview of Literature


The application of game design elements of non-game scenarios is known as gamification. Some authors stated that gamification uses elements of experiences (Deterding
etal., 2011). It must also impart some rules or structure to the experience to influence
participants action. Gamification adds game design elements as well as promoting the
psychological benefits and motivational ability of games but in different contexts.
Programming games are an important part of educational games. A programming
game is a computer game where the player has little or no direct influence on the
course of the game. Instead, a computer program or script is written in some domainspecific programming language in order to control the actions of the characters or
other entities.
There are several definitions of serious games. For example, Alvarez and Michaud
(2008) state that a serious game must include a genuine entertainment element combined
seemingly with a practical dimension. Some researchers argue that all games have a
serious purpose, such as gambling. That is why a majority of simulators would be considered as serious games (Sawyer and Rejeski, 2002).
Game design may be defined as the action of making sense of things related to a
game (Mora etal., 2015, p. 3). Another description is the act of deciding what a game
should be (Schell, 2008, p.xxxviii). Game design is related to enjoyment, while gamification points towards a business objective. Similarity of game design and gamification
design is that both rely on the principles of game design theory.

42

S. Combfis, G. Beresneviius, V. Dagien

2.1. Related Works


The ACM and IEEE computer society state that computer science is becoming one of
the core disciplines of a 21st century university education, that is, something that any
educated individual must possess some level some level of proficiency and understanding of proficiency and understanding (ACM/IEEE, 2013, p. 48). However, there
are a lot of students who are becoming less interested in computer science. Colleges
and universities routinely report that almost half of those students who initially choose
computer science study soon decide to abandon it. There are high dropout rates as well
as high failure rates of high school students in programming courses. Decades of effort
have been put into decreasing these rates.
There were several approaches to motivate students to learn programming. Programming fundamentals may be hard skills to learn for students, especially for novices. In
order to help students, there are several attempts to teach programming by using educational or serious games.
Programming courses are an important part in computer science subjects. Objectoriented programming is difficult for students, especially first year students. The embedding of gamification in programming courses could maximize student participation and
have a positive impact on learning (Azmi etal., 2015). The gamified social activity is designed to promote interaction among students and they may assist and give feedback to
each other online. Online collaborative learning and the participation of students should
be emphasised as well. Moreover, aesthetics is also a very important part in a game,
because it makes it fun, which contributes to engage students in the learning process.
The embedding of gamification in programming courses were analysed and showed that
gamification in online collaborative learning can enhance participation among first year
programming students. The participation is an important part in each computer science
study due to motivation and lower dropout rates.
Vihavainen et al. (2014) present another approach in a literature overview. Their
paper reports about 60 pre-interventions and post-interventions and analyses their influence on students pass rates in programming courses. Statistically, pass rates after these
interventions increased nearly by one third compared to traditional teaching. A more
detailed discussion is presented about seven courses on gamification intervention after
which pass rates increased by 10.8% on average.
Tillmannetal. (2013) deals with an alternative platform called Pex4Fun. On this
platform, grading of traditional MOOCs (Massive Open Online Course) assignments
has been changed to an automated grading assignment system based on the symbolic
execution, designed for students and teachers. This platform is a game-based learning
and teaching environment, where teachers may create interactive games for students.
Students can learn programming by playing programming games in Pex4Fun as well
as having programming duels between each other.
There are several important components of game elements. As Hunicke etal. (2004)
have discovered the game mechanics represents data and algorithms. Game dynamics
is the lifecycle of the mechanics that act to engage a players input and others output.
Also, game aesthetics plays important role in the emotional part of the player in order to
keep them engaged with the game.

Learning Programming through Games and Contests: Overview, ...

43

Several researchers worked on more detailed classification of games. For example,


Azmietal. (2015) classified game elements into three categories 1) game mechanics
(badges, leaderboard, points, levels...), 2)dynamics (personal dynamics desire for reward, personal promotion; social dynamics altruism; achievements, peer collaboration), and 3) aesthetics (challenges). The gamified design needs to embed collaborative
elements for collaboration among the students. Aesthetics is recommended element in
educational games, because it makes the game fun and engages with the learning
process. Online educational game should have the online support as well as collaborative learning.
While there is still scepticism that something called a game could be anything more
than a leisure activity, serious organizations are getting serious results with serious games.
Serious games may be defined as an application with three main components: experience, entertainment, and multimedia (Laamartiet al., 2014). Especially entertainment
dimension in serious games has the potential to enhance the users experience through
multimodal interaction. Additionally, digital serious games contain different media.
The paper of Laamartietal. (2014) overviews studies on serious games in different
application areas including education, well-being, advertisement, cultural heritage, interpersonal communication, and health care. Also, many platforms were analysed and discussed, what the necessary components of the game to be successful are. A survey on digital serious games in general is conducted and a taxonomy of serious games is created.
Several components of serious games were distinguished and categories of criteria
were suggested (Laamartietal.,2014). These criteria may be useful for any programming games as well. So, providing guidance to players within the game is important.
This will provide them with the necessary knowledge and prevents them from feeling
lost or disturbed. Another thing is avoiding negative consequences in the game, because otherwise it may result in the players low performance. Music element makes
players play the game longer, because of more motivation and engagement will be as an
effect of this. Multiplayer collaborative exercise games are more motivating and engaging than single-player appropriate games. Collaborative environment increases players
motivation. It is significantly important to offer challenges in the game for children, but
the challenges must be at the right level (neither too high, nor too low). It is the key in
keeping the players interest in the game. Educational games need to take into consideration sound instructional models to be successful.
More detailed recommendations are provided for educational games designed for
using in a classroom. School teachers are concerned about the curriculum and they also
have limited time resources. It is recommended that educational games would be based
on the curriculum due to the acceptance of many teachers and integration in the class.
Additional recommendations for necessary components of the games to be successfully used can be as follows (Laamartietal.,2014):
a. User-centred software engineering: an important element is the perspective that
the designers contribute to the development teams and the experience that the
player will obtain.
b. Multimodal games: multiple modalities should be incorporated (e. g. visual, auditory and haptic combination).

44

S. Combfis, G. Beresneviius, V. Dagien

c. Social well-being: stimulating a feeling of virtual presence or connectedness of


social well-being in real life.
d. Adaptive gaming: a serious game should adapt or personalize a particular players capabilities, needs, and interests.
e. Standardization of evaluation: heuristic evaluation standards must turn into a
reality. That is useful for acquiring higher credibility.
f. Sensory-based simulations: serious games can be created based on real world
sensory data so that real world scene would be accurately reconstructed.
Many commercial games demonstrate the properties of sound instructional design,
even in games not intended for educational purposes (Becker, 2008). The author has
recommended the following success factors for educational games: 1) Gain attention; 2)
Inform learners of the objective; 3) Stimulate recall of prior learning; 4) Present stimulus material; 5) Provide learning guidance; 6) Elicit performance; 7)Provide feedback;
8) Assess performance; 9) Enhance retention and transfer. These factors were based on
well-known learning and instructional theories.
One suggestion for recreating games is to modify an existing non-educational games
into programming games (Muratetetal., 2010). The authors have used existing online
non-educational games ideas to develop their own serious games. For example, there
is a game Kernel Panic, having following features: it has no resource management
except for time and space; all units are free to create; it has a small technology improvement tree with less than ten units; and it uses low-end vectorial graphics, which match
the universe. In this game a player gives orders to the units to carry out operations (i.e.
moving, building, and so forth). So the authors (Muratetetal., 2010) changed the game
design that the player has to write a program code in order to make the actions of his
units and play. The authors modified some games into serious games and students, e.g.
players may play these games using different programming languages: C, C++, Java,
OCaml, Ada and an interpreted language called Compalgo.
Another paper (Cuba-Ricardo etal., 2015) describes some characteristics and regularities from the behaviour of three students as they solved a programming problem as
well as reveals the methodology stages using several methods, techniques and tools.
The paper is limited by the time of contestants, who have between 60 and 90 minutes in
contest of final states.
Successful computer programmers must have several cognitive skills as listed by
Surakka and Malmi (2004). Contestants opinions must be taken into account in order
to have full view of their outputs. So, it was decided to use computer programs that take
screenshots in short periods of time. The methodology of characterizing the cognitive
process of solving programming problems was organized into five stages:
a. Preparation of the process.
b. Recording the process of exercise application.
c. Analysis, processing and assessing of the partial reports (observation of pictures).
d. An interview session.
e. Final assessment.

Learning Programming through Games and Contests: Overview, ...

45

The implementation of the methodology revealed that programmers took notes in


the worksheets and the reasoning followed when determining the solution algorithm.
So, monitoring programming students actions is a useful method to discover not only
final outputs, but intermediate results of the learning process as well. We think it may
be one of the essential issues to be taken into consideration of teaching programming
curriculum, especially for novices. Monitoring process could be done by computer automated programs and be used as a general method (e.g. it may be a live survey after your
programming contest).
Researchers focus on investigating successful components of educational games that
could help to reduce dropout rates of students in computer science. The embedding of
gamification in programming courses can be one of solutions for that: it can help to
maximize student participation and learning, motivate and reduce dropout rates, especially for novices in programming (Azmietal., 2015). Some platforms, e.g. Prog&Play
may help even to recruit students in computer science (Muratetetal., 2010). Intervention of educational games in programming courses raises pass rates by 10.8% on average
(Vihavainen etal., 2014).
A feedback is an important and necessary part in education and educational games
(Azmietal., 2015; Cuba-Ricardo etal., 2015; Tillmann etal., 2013). Good feedback can
be implemented by providing guidance to players within the game so that they do not feel
lost (Becker, 2008) or by avoiding negative consequences in the game. Another solution is to make the game a multiplayer one to motivate players to play the game longer.
The most successful factors are multiple modalities of games, players collaboration,
adaptive or personalized game components based on real world sensory data (Laamartietal., 2014). Non-educational games may be gamified and used for teaching programming courses as well (Muratet etal., 2010). Contests and duels in programming games
are engaging and may be used to raise programming skills (Cuba-Ricardo etal., 2015).
All the authors that are mentioned in this section have stated that educational games
motivate students to learn. In general, you may use all these researched factors when
your own create programming games.

2.2. Taxonomy of Educational Games


As there is growth of researches in the educational games field and it is a necessity to
improve the value of teaching or learning programming by educational game, we were
working on the taxonomy of educational games. We adapted the framework of serious
games taxonomy based on the paper (Laamarti etal., 2014). Firstly, we will provide a
short introduction to the mentioned taxonomy. After that we will discuss our novelties
and provide a classification of several online programming games.
Five categories for serious games classification are presented by (Laamarti et al.,
2014, p. 6):
1. Application Area refers to different application domains (education, well-being,
training, advertisement, interpersonal communication, health care, others).

46

S. Combfis, G. Beresneviius, V. Dagien

2. Activity. It depends on the activity of a player to play a game (physical exertion,


psychological, mental).
3. Modality. Here it is the channel by which information is sent from the computer to
the human(s) participating in the game (visual, auditory, haptic, smell, others).
4. Interaction Style. The interaction style defines whether the interaction of the
player with the game is done using keyboard, mouse, or Joystick or using some
intelligent interfaces, e. g. a brain interface, eye gaze, movement tracking, and tangible interfaces. The research showed that choosing the right interface may have an
impact on the success of the game.
5. Environment. This criterion defines the environment of the digital game (social
presence, mixed reality, virtual environment, 2D/3D, local awareness, mobility and
online).
We investigated the classification and found limitations, especially when applying
for programming education by using games. For educational online programming games
an extension and adaptation of the proposed taxonomy are needed (Fig. 1).
Application area. So, an application area of programming games is only one education to program educational games. A field of the programming educational games
activity usually is a mental process. We will have in mind that application area of educational programming games is education, activity field is mental and we will omit these
fields as a result.
Modality. Usual modality fields of educational programming games are visual and
auditory, but sometimes it may be haptic.

Fig.1. The classification of the educational programming games (adapted and extended schema of Laamarti etal., 2014).

Learning Programming through Games and Contests: Overview, ...

47

Interaction style. Interaction style in our taxonomy is keyboard/mouse, tangible


interface, brain interface and joystick, because educational games usually may be classified just in these fields. But we remain open to discussion about this question.
Environment. As environments of programming games may be any of Laamarti
etal. suggested environments, we include all of the areas: social presence, mixed reality,
virtual environment, 2D/3D, local awareness, mobility and online.
Learning approach. We include this new field to classification of educational games.
This is because analysed research papers on educational games pays a lot of attention
to successful methods of teaching or learning. We propose that the learning approach of
educational games may be classified into single player, multi player, mixed players (part
of the game may be single-player game and part of the game may be multi-player game),
peers (it is important to pay attention to communication between peers), collaboration
(some educational games may teach team work), support of teachers (students easier
learn while they are playing with a help of teachers/lecturers).

3. Online Platforms for Learning Programming


Several different kinds of online platforms to learn programming do exist. The most
classical platforms are able to automatically execute code and provide feedback. They
provide lessons that the learner can follow and propose interactive coding exercises with
immediate correction. Combfis and le Clment de Saint-Marcq (2012) proposes a short
review of such platforms. Swacha and Baszuro (2013) propose such a classic platform,
but they included game elements in it. For example, the courses in their platform are
characterised by the set of completed areas, the number of earned points and the attained
level. Moreover, it is possible to challenge other students and take part in contests.
In addition to the specific platforms to learn coding and programming, online courses
are also proposed in the form of MOOCs (Combfis etal., 2014). Another example is
Khan Academy, which provides interactive lessons and videos with coding exercises
(Morrison and DiSalvo, 2014). Both these kinds of platforms propose a full course with
videos for the theory and then practical coding exercises with more or less detailed direct
automated feedback. They are designed with the learning process as the main objective.
This section presents three main categories of online game platforms with different
goals: learn to code, learn algorithmic thinking and learn to create games. Proposed examples are discussed according to the background presented in the previous section, for
the particular case of learning computer science skills. The last subsection, then discusses
how and what game elements can be added to an online platform in order to gamify it.

3.1. Learn to Code


The first category of game platforms contains those whose goal is to make their users
learning and training to code. Coding games require the learner to understand and to be

48

S. Combfis, G. Beresneviius, V. Dagien

able to write code to solve challenges. Different coding activities are possible, the main
ones being:
Bugfix: the user is given a program that contains a bug to be fixed.
Recovery: the user is given a program where some parts are missing that have to
be filled.
Code writing: the user has to write an instruction, a function or a program from
scratch.
Agent: the user has to write a program that represents the behaviour of an intelligent agent.
To help the learner to identify the bug, additional information is provided in the statement of the challenge. For example, a precise specification of the program or the results
of the execution of test sets can be provided. Once the learner has written/fixed the
code, he submits it and then gets a feedback. As summarised by Combfis and Wautelet
(2014), feedback is very important for the learning process. Those feedbacks can take
several forms such as:
A simple succeeded/failed status.
The result of the execution of test sets.
A textual feedback providing hints regarding the failure.
Codecademy is an example of an online game platform to learn how to code (Fig.2).
The left part of the window provides the explanations of the new concept to learn. Instructions about the exercise are then provided at the very bottom of this left pane. The
learner can directly code in the editor located in the right part and then submit his/her
code for correction. If the code is wrong, a simple feedback trying to explain why is
provided and if it is right the learner earns a badge, increases his/her progress and can
go to the next lesson.

Fig. 2. Codecademy proposes a course composed of lessons in which you have to write code
and for which you will earn badges and make progress whenever you succeed.

Learning Programming through Games and Contests: Overview, ...

49

3.2. Learn Algorithmic Thinking


Coding is not the only field of computer science that can be taught through online platforms. As described by Combfisetal. (2013), it is also possible to grow algorithmic
thinking through interactive problems, in particular to learn programming concepts.
For example, LightBot (https://lightbot.com) is used to learn the notion of programming and in particular recursion through a simple game where the user has to solve
puzzles. Each puzzle requires the learner to write a program composed of visual blocks
to drive a robot to a goal. Fig. 3 shows the main window of the game where the robot
and its environment are shown on the left and the program representing the behaviour
of the robot is shown on the right. LightBot is not a platform to learn how to code, but to
teach programming concepts. In the more advanced levels, the notions of function and
therefore recursion are introduced.
Another example is Initial Conditions (https://reheated.org/games/initial), shown in Fig. 4, where the player has to find a solution to a search problem. In
this game, the player faces to a grid with rivers and has to place a certain number of
villages so that a river passes through them and so that no two cities are adjacent (horizontally or vertically).

Fig. 3. In LightBot, the player has to find a correct sequence of actions to perform so that the
robot reaches the blue cell and lighten it.

Fig. 4. In Initial Conditions, the player has to place cities on a map so that a river is passing
through them and so that two cities cannot be adjacent. This particular map has one river and
the player has to place five cities.

50

S. Combfis, G. Beresneviius, V. Dagien

This problem is a typical an artificial intelligence (AI) search problem that could for
example be solved using any exploration algorithms, or with a constraint programming
solver, for example. Again, it is not explicitly explained to the learner who just sees a
game with puzzles to solve. Playing the game will challenge the learner and should develop algorithmic thinking in learners mind.
Again, if the purpose is educational, the provided feedback is very important. For
LightBot, the feedback is visual since the learners can visualise the execution of their
programs and therefore visually debug them if the robot failed to reach the goal. For
Initial Conditions, the only feedback is a success/failed status indicating which cities are
violating the constraints or which river is missing villages.

3.3. Learn to Create Games


Finally, another kind of online programming learning platforms offers the possibility for
the users to create their own games. On these platforms, the learner has to program a
game, typically with a visual programming language. For example, Scratch (https://
scratch.mit.edu) uses a visual block programming language to program the behaviour of sprites.
The main window of the application where the game is shown on the left part and the
code is shown on the right (Fig. 5). The behaviour of each sprite can be programmed and
they can also communicate together.
Another similar platform is Flowlab (http://flowlab.io) where the game is represented by flowchart diagrams (Fig. 6). As in Scratch, the game is built with sprites
whose individual behaviours can be programmed.

Fig. 5. The main window of the Scratch program is split into two parts: the left part shows
the sprites of the game and the right part shows the programs representing the behaviour of
the different sprites.

Learning Programming through Games and Contests: Overview, ...

51

Fig. 6. In Flowlab, the user programs the game using flowchart diagrams representing the
behaviours of the different sprites it included in the game.

This last category requires the learner to be able to program, but not necessarily to
write code. The focus is put on the creativity and on the skills needed to design and architecture an application.

3.4. Gamification of an Online Learning Platform


Proposing an online platform is useful to make the material available to every learner.
But only relying on the online aspect is not enough to motivate them to learn. As detailed
in the second section, gamification can help to foster learners to make progress, increasing their engagement and motivation. Several kinds of elements can be introduced to
build online game platforms:
Points and rankings amongst players.
Levels, grades, badges that are related to the progression.
Live fights/contests between players or against bots.
One other important element that can be taken into account is the contextualisation
of the statements of the challenges and exercises. There are indeed two main strategies that can be used to gamify an online platform to learn programming. Either game
elements can be added to an already existing platform (points, rankings, badges) or
the platform can be rethought and redesigned so that to transform it completely into

52

S. Combfis, G. Beresneviius, V. Dagien

a game. As highlighted by Morrison and DiSalvo (2014) who relate the gamification
of the Khan Academy, one critical motivational element to have is to place the user
at the centre by adding elements of pure play, to make the gaming more playful.
Examples of such approaches include CodeSpells (Esper etal., 2013) and Gidget (Lee
etal., 2013).
Ibez et al. (2014) made an experiment to explore the impact of gamification
techniques on the engagement and learning about the C programming language. The
authors conclude that the gamification they performed has a positive impact on the
students engagement. Most students continued to work even after having earned the
maximum amount of points. ODonovan etal. (2013) present a case study where they
used gamification in a university-level course about game development. In their paper, the authors provide insights about gamification mechanics and explain how the
design of their game has been created and which game elements have been used. Their
research allows them to conclude that the gamification they performed in a university
setting was effective, increasing the engagement and understanding of the students.
Again, it is a situation where the platform has been thought as a game from the starting point.

4. Online Programming Contests


This section presents several online game platforms, so that to cover the different tendencies that exist today and the characteristics presented in the previous section. The
focus has been put on platforms that available for free (at least a standard version).

4.1. Leek Wars


Leek Wars (http://leekwars.com/) is a game where the player has to program the
behaviour of a leek. The goal of the leek is to defeat another leek during a fight that takes
place in a garden. Depending on the level of the player, his/her leek can be equipped with
more weapons, health-recovering objects, etc.
The leeks are programmed in JavaScript and an API provides functions to manipulate the leak and to get information about the environment. This API is very well documented, which also trains learners to manipulate such documentation.
The platform offers the possibility to develop several AIs and to choose which one
to use at any time. The player can experiment his/her AIs against bots, before jumping
into the garden to fight with other real players. To motivate the player, a level system has
been put in place. For each fight that is won, the player gains experience points, which
allow him/her to level up. A higher level grants access to more objects such as weapons,
magic spells, etc. It also improves the ranking of the player.
The game also proposes a cooperative mode where teams composed of leeks belonging to different players can fight against other teams. Such cooperative mode is another
technique used in games to foster people to play regularly.

Learning Programming through Games and Contests: Overview, ...

53

Fig. 7. Two leeks are fighting in a war, playing alternatively one after the other. The garden is
divided into cells between which the leeks are moving and has some impassable obstacles.

4.2. CodinGame
CodinGame (https://www.codingame.com) proposes coding challenges to solve.
Basically, the user is asked to code agents that have to interact in a given environment
in order to achieve a given goal. In the example shown in Fig. 8, the user has to code the
spaceship so that to destroy all the targets on the ground. The spaceship is moving from

Fig. 8. In this mission, the agent is a spaceship that must destroy targets on the ground. These
targets have different heights so that the spaceship must destroy them in the right order if it
does not want to enter in collision with any of them.

54

S. Combfis, G. Beresneviius, V. Dagien

left to right then back from right to left while descending when it reaches the rightmost
part of the world. The difficulty is that targets have different heights and the spaceship
must avoid entering in a collision with any of them.
Several test sets are provided and to succeed, the code of the player must pass them
all (some being public and others being hidden). The execution of the code also results
in an animation, which makes it possible for the learner to directly visualise the behaviour he/she wrote. This latter point helps to increase the motivation and engagement of
the learner, better than a simple textual test execution report. Finally, the platform offers the possibility to code the agents with a lot of different programming languages.
Several challenges/missions are available for the user to tackle. They are organised
into categories such as tutoring, advanced, etc. The users can follow their progress and
that motivates to solve more challenges.

4.3. Code Hunt


CodeHunt (https://www.codehunt.com) is developed by Microsoft Research and
propose coding challenges driven by tests. The goal of the game is to guess what the
code must do, and then fix it until it passes all the tests. Fig. 9 shows the main view of
Code Hunt where the code is on the left and the results of test execution are shown on
the right. Pressing the Capture code button triggers the execution of a bunch of tests,
shown on the right.
When the user solves a yet unsolved puzzle, he/she gains points so that to increase
his/her position in the ranking. Moreover, some puzzles are initially locked and will only
unlock when the user has solved enough puzzles. This possibility to unlock puzzles is an
incentive for the user that motivates him/her to progress.

Fig. 9. The main window of Code Hunt is split into two parts: the left part shows the code
being run and the right part shows the result of the execution of the public tests.

Learning Programming through Games and Contests: Overview, ...

55

4.4. Code Fights


Code Fights (https://codefights.com) is a platform where users can participate
in fights against bots or other real players. A fight typically consists in three puzzles to
solve. One fight typically consists of three challenges. As shown in Fig. 10, the main
window shows the statement of the challenge on the right and the code with the results
of public tests on the right.
The learner can train him/herself by fighting bots or can defy any other player for a
fight. There are two kinds of bots: simple ones and others developed by companies. If
you manage to beat a company bot, you got a chance to be contacted by the company
to possibly get a job. Another interesting feature proposed by the platform is tourney,
where you compete with several other real players on the same challenges. To win the
tourney you have to solve all the challenges as fast as possible.

4.5. Discussion and Comparison


The presented online platforms have some common points and differences. First of all,
they are all in the learn algorithmic thinking category described in the previous section. Then, the level of gamification of the different platforms is quite different. A platform that has been completely designed with games in mind is one that completely
agrees with the definition of gamification, as detailed in the previous section. The first
one, namely Leek Wars, is a full online game with cooperative aspects where the ultimate goal is for the player to level up to become the best leek, the one with the most

Fig. 10. The main window of Code Fights is split into two parts: the left part shows the statement of the challenge and the right part shows the code and the result of the execution of the
public tests.

56

S. Combfis, G. Beresneviius, V. Dagien

intelligent behaviours. The three other platforms do contain some game element, but
they are not designed completely as full games. Table 1 summarises the game elements
that appear in the presented platforms.
All the platforms presented in this paper can also be classified according to the
adapted and extended schema we proposed to classify educational programming games.
Table2 shows how that classification can be done. All the games presented in this paper
Table 1
The four presented online game platforms to learn different skills of coding training and
contains different game elements
Platform

Trained skills

Game elements

Leek Wars

Coding agents AI
Inventing algorithms

CodinGame

Understanding specifications
Coding objects behaviours

Code Hunt

Points and rankings


Challenges against bots and other players
Cooperative mode
Points, trophies, badges, rankings
Levels and achievements
Matches against other players
Points and rankings
Levels with challenges to unlock

Fixing bugs
Code recovery
Understanding tests sets results
Understanding specifications
Points, levels and rankings
Coding algorithms
Matches against other players or bots
Fixing bugs
Code recovery

Code Fights

Table2
Classification of the platforms

Game

Modality

Interaction style

Environment

Learning approach

Codecademy

Visual

Keyboard/Mouse

Single Player

Code Fights

Visual

Keyboard/Mouse

Code Hunt

Visual

Keyboard/Mouse

CodinGame

Visual

Keyboard/Mouse

Initial Conditions Visual

Keyboard/Mouse

Leek Wars

Visual

Keyboard/Mouse

LightBot

Visual

Keyboard/Mouse

Social Presence
2D
Online
Social Presence
2D
Online
2D
Online
Social Presence
2D
Online
2D
Online
2D
Online
2D
Online

Mixed Player
Single Player
Single Player
Single Player
Mixed Player
Collaboration
Single Player

Learning Programming through Games and Contests: Overview, ...

57

are visual ones with which the players interact with the keyboard and mouse. Concerning the environment, all the games are of course online ones. They are also all 2D games
and some of them will require social presence, in particular for those where duels are
available. Finally, the learning approaches of those selected games can be either single
or mixed player. One of the game, namely Leek Wars, supports collaboration through the
creation of teams of Leeks.

5. Recommendations and Conclusions


To conclude this paper, the learning of programming is accessible not only to higher
education students, but it is accessible to others as well. A lot of online platforms have
been developed and made accessible on the Internet. In addition to the classical learning platform or MOOCs, a broad range of game-based online platforms have emerged.
The main advantage of such platforms is that they foster their users to learn and keep
progressing, making programming fun.
Tasks and challenges proposed by these games-based platforms could inspire tasks
proposed in the IOI for two main reasons. First, contestants to the IOI are probably using
those platforms so that they may be expecting similar tasks at the IOI. Second, the motivational aspect of those tasks could be transferred to the IOI contest, also the making it
more motivational and interesting for its contestants.
We referred and analysed papers on gamification: contests; online platforms; online,
educational, programming and serious games. These are our main findings from these
papers for educational or serious programming games to be successful, motivating to
learn programming and so on:
a. Feedback and assessment is very important in any educational games. Assessment
may be automated or not, but it raises efforts of students. Feedback provides information about the learning process.
b. Games must have aesthetics game must be fun to engage and improve intrinsic
motivation to learn computer science or programming.
c. Collaborative educational games raise the participation of students.
d. Participation is necessary for motivation to learn as well as for reducing high
dropout rates of programming students.
e. Multiplayer collaborative games are more motivating and engaging than singleplayer appropriate games.
f. Guidance in educational game helps players not to feel confused while they are
playing.
g. Aesthetics make any educational game fun. It involves players into the game.
h. Avoid negative consequences, because otherwise players may perform low.
i. Involve music in game design and the players will probably play the game longer.
j. The level of challenge neither ought to be not too low nor too high (it keeps the
interest of players).
k. Games with multiple modalities, adaptive or personalized, based on real world
sensory data may be more successful.

58

S. Combfis, G. Beresneviius, V. Dagien

l. Contests and duels in programming games may be used to improve the programming skills.
We proposed taxonomy of the programming educational games and classified several
online programming games / platforms. All of these games are visual; interactive with
keyboard/mouse, 2D and online. The majority of them are designed for a single player,
however, two of them are designed for mixed players (game may be played as single
player or multiplayer) and one of them involves collaboration aspect. As we already
mentioned, multiplayer and collaborating games are more motivating. 3D-games sometimes have more advantages than 2D, but it depends more on a combination of many
other mentioned or not mentioned factors.
Our findings may be useful in creating educational programming games on your
own, or recreating non-educational games and gamifying them to teach programming, it
is especially useful for novices in programming. This research does not propose to use
all these factors, because some of them may be successful in one kind of games, but may
not be successful for other type of games. However, it is recommended to use at least
some of these factors due to our research analyse.

References
ACM/IEEE Computer Society (2013). Computer Science Curricula 2013.Curriculum Guidelines for Undergraduate Degree Programs in Computer Science. ACM Press, New York, N. Y. USA. Available on the
internet: https://www.acm.org/education/CS2013-final-report.pdf
Alvarez, J., Michaud, L. (2008). Serious games: advergaming, edugaming, training, and more, IDATE, BP 4167,
34092 Montpellier Cedex 5. France, 36, 1112.
Arena, D.A., Schwartz, D.L. (2013). Experience and explanation: using videogames to prepare students for
formal instruction in statistics. Journal of Science Education and Technology, 111.
Azmi, S., Iahad,N.A., Ahmad, N. (2015). Gamification in online collaborative learning for programming courses: a literature review. ARPN Journal of Engineering and Applied Sciences, 10(23), 13.
Barata, G., Gama, S., Jorge, J., Goncalves, D. (2013). Engaging engineering students with gamification. In:
Proceedings of the 5th International Conference on Games and Virtual Worlds for Serious Applications
(VS-GAMES 2013). 18.
Becker, K. (2008). Video game pedagogy: good games = good pedagogy. In: T.C. Miller (Ed.), Dames: Purpose
and Potential in Education. Springer, NewYork, NY, 73125.
Bishop, J., Horspool, R., Xie, T., Tillmann, N., de Halleux, J. (2015). Code hunt: experience with coding contests at scale. In: Proceedings of the 37th International Conference on Software Engineering (ICSE 2015).
398407.
Combfis, S., Bibal, A., Van Roy, P. (2014). Recasting a traditional course into a MOOC by means of a SPOC.
In: Proceedings of the European MOOCs Stakeholders Summit 2014 (EMOOCs 2014). 205208.
Combfis, S., Saint-Marcq, D. (2012). Teaching programming and algorithm design with Pythia, a web-based
learning platform. Olympiads in Informatics, 6, 3143.
Combfis, S., Van den Schrieck, V., Nootens, A. (2013). Growing algorithmic thinking through interactive
problems to encourage learning programming. Olympiads in Informatics, 7, 313.
Combfis, S., Wautelet, J. (2014). Programming trainings and informatics teaching through online contest.
Olympiads in Informatics, 8, 2134.
Cuba-Ricardo, G., Serrano-Rodrguez, M.T.,Leyva-Figueredo, P.A., Medoza-Tauler, L.L. (2015). Methodology
for characterization of cognitive activities when solving programming problems of an algorithmic nature.
Olympiads in Informatics, 9, 2730.
Deterding, S., Dixon, D., Khaled, R., Nacke, L. (2011). From game design elements to gamefulness: Defining
gamification. MindTrek, 2.
Dickey, M.D. (2005). Engaging by design: how engagement strategies in popular computer and video games
can inform instructional design. Educational Technology Research and Development, 53(2), 6783.

Learning Programming through Games and Contests: Overview, ...

59

ODonovan, S., Gain, J., Marais, P. (2013). A case study in the gamification of a university-level games development course. In: Proceedings of the South African Institute for Computer Scientists and Information
Technologists Conference (SAICSIT 2013). 242251.
Esper, S., Foster, S., Griswold, W. (2013). CodeSpells: embodying the metaphor of wizardry for programming.
In: Proceedings of the 18th ACM Conference on Innovation and Technology in Computer Science Education
(ITiCSE 2013). 249254.
Gee, J.P. (2003). What video games have to teach us about learning and literacy. Computers in Entertainment
(CIE), 1(1), 20.
Gee, J.P. (2005). Good video games and good learning. Phi Kappa Phi Forum, 85(2), 3337.
Hunicke, R., Leblanc, M. Zubek, R. (2004). MDA: A formal approach to game design and game research. In
Proc. AAAI workshop on Challenges in Game. AAAI Press, 15.
Ibez, M.-B., Di-Serio, ., Delgado-Kloos, C. (2014). Gamification for engaging computer science students in
learning activities: a case study. IEEE Transactions on Learning Technologies, 7(3), 291301.
Laamarti, F., Eid, M., El Saddik, A. (2014). An overview of serious games. International Journal of Computer
Games Technology. Article ID 358152, vol. 2014, 115. Available on the internet:
http://dx.doi.org/10.1155/2014/358152
Lee, M., Ko, A., Kwan, I. (2013). In-game assessments increase novice programmers engagement and level
completion speed. In: Proceedings of the 9th Annual International ACM Conference on International Computing Education Research (ICER 2013). 153160.
Maloney, J., Burd, L., Kafai, Y., Rusk, N., Silverman, B., Resnick, M. (2004). Scratch: a sneak review. In: Proceedings of the 5th International Conference on Informatics in Schools: Situation, Evolution and Perspectives (ISSEP 2011). 155164.
Mora, A., Riera, D., Gonzlez, C, Arnedo-Moreno, J. (2015). A literature review of gamification design frameworks. In: 7th International Conference on Games and Virtual Worlds for Serious Applications (VS-Games),
At Skvde. IEEE, 18.
Morrison, B., DiSalvo, B. (2014). Khan Academy Gamifies Computer Science. In: Proceedings of the 45th
Technical Symposium on Computer Science Education (SIGCSE 2014). 3944.
Muratet, M., Torguet, P., Viallet, F., Jessel, J.-P. (2010). Experimental feedback on Prog&Play: a serious game
for programming practice. In: L. Kjelldahl and G. Baronosk (Eds.), EUROGRAPHICS. 18.
Nah, F., Zeng, Q., Telaprolu, V., Ayyappa, A., Eschenbrenner, B. (2014). Gamification of education: a review of
literature. In: Proceedings of the First International Conference on HCI in Business (HCIB 2014). 401409.
Prensky, M. (2003). Digital game-based learning. Computers in Entertainment (CIE), 1(1), 21.
Ravaja, N., Saari, T., Laarni, J., Kallinen, K., Salminen, M., Holopainen, J., Jrvinen, A. (2005). The psychophysiology of video gaming: phasic emotional responses to game events. In: Proceedings of DiGRA
2005 Conference: Changing Views Worlds in Play. Vancouver, Canada, 3, 113.
Sawyer, B., Rejeski, D. (2002). Serious Games: Improving Public Policy through Game-Based Learning and
Simulation. Woodrow Wilson International Center for Scholars, Washington, DC, USA.
Schell, J. (2008). The art of Game Design: A Book of Lenses. Carnegie Mellon University and Schell Games,
Pittsburgh, Pennsylvania, USA.
Shute, V.J. (2011). Stealth assessment in computer-based games to support learning. In: S. Tobias and D. Fletcher (Eds.).Computer Games and Instruction. Information Age: Charlotte N. C., 503524.
Squire, K. (2008). Open-ended video games: a model for developing learning for the interactive age. In: K.
Salen (Ed.), The John D. and Catherine T. MacArthur Foundation Series on Digital Media and Learning.
MA: The MIT Press, Cambridge, 167198.
Surakka, S., Malmi, L. (2004). Cognitive skills of experienced software developer: Delphi study. In: Korhonen
A., Malmi, L. (Eds), Kolin KolistelutKoli Calling 2004. In: Proceedings of the Fourth Finnish/Baltic Sea
Conference on Computer Science Education. Finland, Koli, 3746.
Swacha, J., Baszuro, P. (2013). Gamification-based e-learning platform for computer programming education.
In: Proceedings of the X World Conference on Computers in Education (WCCE 2015). 122130.
Tillmann, N., de Halleux, J., Xie, T., Bishop, J. (2014). Code hunt: gamifying teaching and learning of computer science at scale. In: Proceedings of the First ACM Conference on Learning @ Scale Conference (L@S
2014). 221222.
Tillmann, N., De Halleux, J., Xie, T., SumitGulwani, Bishop, J. (2013). Teaching and learning programming and
software engineering via interactive gaming. In: 35th International Conference on Software Engineering
(ICSE). IEEE, San Francisco, CA, 11171126.
Vihavainen, A., Airaksinen, J., Watson, Ch. (2014). A systematic review of approaches for teaching introductory
programming and their influence on success. In: ICER 14Proceedings of the tenth annual conference on
International computing education research. ACM, New York, NY, 1926.

60

S. Combfis, G. Beresneviius, V. Dagien

S. Combfis obtained his PhD in engineering in November 2013 from


the Universit catholique de Louvain in Belgium. He is currently working as a lecturer at the cole Centrale des Arts et Mtiers (ECAM),
where he is mainly teaching informatics. He also got an advanced
master in pedagogy in higher education in June 2014. He founded the
Belgian Olympiad in Informatics (be-OI) with Damien Leroy in 2010.
In 2012, he introduced the Bebras contest in Belgium and at the same
time he founded the CSITEd non-profit organisation that aims at promoting computer science in secondary schools.
G. Beresneviius is a doctoral student of informatics engineering at
the Institute of Mathematics and Informatics of Vilnius University. He
obtained his master degree in Mathematics and Informatics Didactics
with Cum Laude diploma in Vilnius University. His research focuses
on teaching informatics, especially programming through games, as
well as the theories of serious games and gamification. He participated
in several international conferences and presented his research. He
likes programming websites using HTML, CSS, JavaScript, PHP and
MySQL languages.
V. Dagien is head of the Informatics Methodology Department at the
Institute of Mathematics and Informatics of Vilnius University. Her
current research is in Computer Science Education, focusing on cognitive aspects of algorithmic thinking as well as computational thinking. She has published over 200 scientific papers and methodological
works, has written more than 50 textbooks in the field of informatics and information technology for primary and secondary education.
She works with various expert groups all over the world. In 2004, she
established the Bebras Challenge on Informatics and Computational
Thinking, which is successfully implemented in more than 50 countries. She has participated in several EU-funded R&D projects, as well
as in a number of national research studies connected with technology
and education.

Olympiads in Informatics, 2016, Vol. 10, 6172


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.04

61

The Place of the Dynamic Programming Concept


in the Progression of Contestants Thinking
gnes Erdsn Nmeth1,2, Lszl ZSAK3
Batthyny High School, Nagykanizsa, Hungary
Doctoral School, Faculty of Informatics, Etvs Lornd University, Budapest, Hungary
3
Faculty of Informatics, Etvs Lornd University, Budapest, Hungary
e-mail: erdosne@blg.hu, zsako@caesar.elte.hu
1
2

Abstract. The special problem-solving strategies have been receiving a lot of attention lately,
whether it is teaching computational thinking for all or computer science for competitors. A didactically interesting question is how problem solving can be developed in childrens minds, what
steps and tasks lead through from understanding the idea to its professional usage. In this paper
we present and explain how and in what forms the given problem-solving strategies, especially
the dynamic programming concept, appear in childrens informatics studies: from CS unplugged
activities through Bebras tasks and national CS competitions to efficient coding at the IOI.
Keywords: dynamic programming concept, teaching informatics in primary and secondary
schools, preparing for contests.

1. Overview
There are a lot of problem-solving strategies which every contestant has to be familiar
with. In this paper, we want to focus on one of the most important ones, specifically dynamic programming, because [Until] you understand dynamic programming, it seems
like magic (Skiena, 2008).
The dynamic programming name came from Bellmann in the 1950s (Dreyfus,
2002). He wanted to find a name for the multistage decision making process, in which
the general case is very hard to solve thus one must use the divide & conquer concept. It
leads back to special cases, when the solution is expressed more easily not in terms of
the unknown function, but in terms of an action or decision.
If we want to speak about dynamic programming, we also have to examine other corresponding concepts, like recursion, memoization and divide & conquer.
The concept of recursion consists of a recursive function and a recursive implementation; it is a top-down approach. Usually the runtime of the algorithm is exponential
and this technique usually fails already in a small sample size. The memoization is a
top-down approach as well, it is more effective than recursion. The core idea is the

62

. Erdsn Nmeth, L. Zsak

same: recursive function and recursive implementation, but storing the calculated results, thus without calling the recursive step again when the actual state previously
appeared.
When we are experienced enough to implement a recursive approach correctly,
there is a special technique for dramatically reducing the runtimes of certain algorithms from exponential to polynomial or from factorial to exponential, at the expense
of higher memory usage. This is done by solving sub-problems and storing the results
using a dynamic programming concept. The concept is about a recursive function, but
the implementation is to build the values from bottom up without calling the recursive
step repeatedly.
The simplest type of dynamic programming is when an array is filled namely a
table cell-by-cell in a predetermined order, implementing the recursive function from
bottom up. We will call it a basic DP.
Some people use the term dynamic programming only for those recursive problems,
which involve optimization, but the technique of completing a table to solve any other
type of problem is almost the same when it comes to implementing the solution. We will
call it classic DP.
The dynamic programming as problem-solving strategy is the implementation of the
following five steps (Horvth, 2004):
1. Analysing the (optimal) solutions structure.
2. Dividing it into subproblems and components:
a. Dependence of components must be acyclic.
b. Every subproblem (optimal) solution should be a (recursive) expression of
components (optimal) solution.
3. Expressing each subproblems (optimal) solution as a (recursive) function of components (optimal) solution.
These three steps are the planning of recursive algorithm. DP comes from the next
two steps:
4. Calculating subproblems (optimal) solutions from bottom up (completing a table).
5. Calculating an (optimal) solution from the previously calculated and stored information.
If you are familiar with the basic DP techniques then you could continue with some
advanced techniques (Steinhardt, 2008).
The first advanced type is to keep track of all possible transition states. In this case
DP means filling out a table row-by-row, with the values depending on the row number
and values in the previous row.
Second advanced type is the dynamic greedy type.
The third advanced type is a steady state convergence, only for more experienced
students. In this case the recursive equation must be repeatedly applied, then values will
converge exponentially to the correct values.
All of the DP types have a place in different stages and in different ages of contestants studies.

The Place of the Dynamic Programming Concept in the Progression ...

63

2. Place of Dynamic Programming in Algorithms Textbooks


There are a lot of textbooks about algorithms. They discuss all algorithms sequentially
and directly as they are written for university students. The structure of these books and
the place of dynamic programming in them is different.
In the textbook of Skiena (2008) the DP takes place after data structures, sorting and
selecting algorithms, graphs, combinatorics, backtrack and parallel programming. In the
chapter of dynamic programming, he compares algorithms using cache vs. computation at first. After this, he discusses the problem of string matching, longest increasing subsequence and partition problem. The limitation of DP is presented via travelling
salespersons problem and there are some words about correctness and efficiency of DP.
Just after the DP concept comes the recursion and memoization, the concepts of the topdown structures.
In the textbook of Kleinberg and Tardos (2006) there are basic algorithms, graphs and
greedy algorithms first. To process sets which can be divided into independent parts they
recommend divide & conquer concept. Just after this method, they speak about DP: the
recursion, the memoization and iteration over sub-problems are the parts of this chapter.
In the textbook of Dasgupta et al. (2006), dynamic programming is presented after arithmetics, primes, cryptography, hashing, divide & conquer, graphs and greedy algorithms via
examples: travelling salesmans problem, longest increasing subsequence and knapsack.
In the textbook of Sedgewick and Wayne (2011) there is no chapter dedicated to DP,
but the concept appears in some points of the book.
In the textbook of Gupta (2009) DP comes after introduction to algorithms, divide &
conquer method and greedy method.
Bebis (2007) has lot of chapters about sorting and searching methods, DP comes
after that.
There are not two textbooks, in which the place of DP is the same in the sequence
of algorithms. Sometimes it comes before graphs (Gupta, 2009), often it comes after
graphs. Occasionally it is before recursion (Kleinberg and Tardos, 2006), but in the most
common order its place is after recursion and memoization. Sometimes it is placed before the greedy algorithms, sometimes after. Textbooks do not usually stress the differences between dynamic programming and greedy approach, nor warn they about the
danger of accidentally using one instead of the other.
These textbooks are almost useless for primary and secondary school pupils because
of their advanced mathematics and informatics contents. Some parts of them may be
useful in upper secondary, just for contestants preparing for IOI.

3. New Way for Contestants Learning DP in Upper Secondary School


Last year there was a paper in IOIJournal about the critical analysis of textbooks and
new way of teaching DP (Foriek, 2015) for upper secondary school students preparing
for national olympiads and IOI. He started with the Fibonacci sequence something is

64

. Erdsn Nmeth, L. Zsak

well-known by children from math studies implementing it with a recursive function


and making this function more efficient with memoization. He compares iterative and
dynamic solution, then introduces DP bottom-up. He demonstrates that the exponential
solution longest common subsequence problem with a top-down approach turns polynomial (o(n2)) with a bottom-up approach. It is a very good structure if students want to
prepare for olympiads all at once.
There is a book about competitive programming, which was written for contestants
preparing for ACM ICPC and IOI (Halim and Halim, 2014). It is not a real textbook, it
teaches the effective type detection of tasks and the correct, error-free coding, not the
concepts behind the algorithms. According to it contestants main goal should be to
honing [their] ability to recognize a problem as DP, finding the recursive formula for
such a problem, coding the problem, and doing all of this quickly.
After data structures and problem-solving strategies like searching iterative & recursive divide & conquer concept and greedy algorithms comes dynamic programming through an example: UVA 11450 wedding shopping. The chapter begins with the
repetition of recursion, backtrack, optimization and counting problems. It shows, that
this tasks solution: greedy method failed with wrong answer (WA), divide & conquer
method failed with WA (because of non-independent parts), complete search failed
with time limit exceeded (TLE). The dynamic programming method with top-down
(memoization) and with bottom-up approach is working. After this very detailed analysis he gives six more example with analysis and many task recommendation to become
familiar with this method.
We think these methods work effectively for students in upper-secondary-school-age
(grade 1113) preparing purposefully for national and international olympiads.

4. Teaching Dynamic Programming in Primary and Secondary School


If the students know structured programming concept (Floyd), they are familiar with
the top-down concept too, because of stepwise refinement; and they are familiar with
the concept of bottom-up, because concrete objects and functions. So the pupils knows
top-down and bottom-up paradigms as soon as they begin to implement a computer
program.
We think teaching dynamic programming ideally begins in upper primary school in
mathematics and informatics lessons. Implementation of DP on computers is possible
when children are familiar with the basic data structures (integer, boolean, array), basic
algorithms (sequence, iteration, selection, searching, procedures and functions) and the
concept of recursion.

4.1. CSUnlugged
There is not any activity yet that covers dynamic programming in the CSUnplugged repository, but there is an intention to make a good one from the change-making problem.

The Place of the Dynamic Programming Concept in the Progression ...

65

4.2. BEBRAS
In the Bebras competitions there are tasks about DP every year. There are other tasks,
in which the recursion is the best solution. There are many in which the greedy gives
wrong answer and the dynamic programming concept must be used for the right solution.
On Bebras competitions the DP problems appear in a wide range of age groups and
difficulties also. It proves that the concept of DP comes much earlier than at the end of
secondary school and it is understandable for everybody, not only for contestants: it is
part of computational thinking skills.
The easiest task of DP is from 2013 for grade 58: the Pairs without Crossing (Kreuzungsfreie Prchen). The brute force algorithm is working, but takes long time to try
every possible connection pairs, the dynamic concept make it easy. In 2011 the problem
Earn coins (Mnzen verdienen) is a special case of the classic knapsack problem. This
one was one of the hard problems for the grade 56, middle for grade 78 and easy for
grade 910. In 2014 another classic DP problem appeared, the Expensive Bridges (Teure
Brcken) which one was hard problem for the grade 78, middle for grade 910 and easy
for grade 1113.
There are more problems connected to DP for secondary-school-age students: the
Jumping Puddles (Ptzenspringen), the game ROOK, in 2010 the task Pinecone (Tannenzapfen), in 2014 the Best translation (Beste bersetzung) and in 2015 the Fireworks2
(das Feuerwerk2).

4.3. Tasks for Contestants of Upper-Primary-School-Age


In the grade 56 we could start with LOGO programming. It provides a strong foundation in the basic programming structures, like sequence, iteration and selection.
Through the drawings, it also visualizes the concept of recursion well. They can imagine and implement binary tree (Fig. 1), the Sierpinski-triangle (Fig. 2), the Koch-curve
(Fig. 3).

Fig. 1. Binary tree.

Fig. 2. Sierpinski-triangle.

Fig. 3. Koch-curve.

66

. Erdsn Nmeth, L. Zsak

In Hungary and many other countries, they meet table filling and the thought of
recursion in mathematics. They calculate total number of possible paths in a grid of
characters, from the top-left corner to the right-bottom corner to spell a given word
(Fig. 4). They calculate total number of possible paths, even if there are empty squares
in the grid (Fig. 5).

Fig. 4. Spelling a given word.

Fig. 5. Spelling a given word with a pit.

Pupils of grade 78 meet simple recursive sequences and functions, like the Fibonacci sequence. In mathematics lessons, they meet combinatorial problems (permutation, variation and combination without repetition) without naming them. They come
across problems, like longest/shortest path in a directed/undirected graphs and coloring
problems on very small graphs, coin changing problem for small numbers, shaking
hands/sitting in a row/around a table, they calculate extreme values in Diophantine
problems. These problems are solved with table filling or with recursive expressions.

The formulas, like n! or are not formulated.


They can solve problems like these:

How many different, 10cm high towers can build from 2 cm high blue, 2 cm high
yellow and 1 cm high red building blocks?

Fig. 6. a1 = 1, a2 = 3, a3 = 5, a4 = 11 Counting with drawing systematically.

If they draw it systematically (seeing the blocks from bottom), they can guess the
recursive expression an = an 1 + 2*an 2 and they check it empirically. The solutions are: 1, 3, 5, 11, 21, 43, 85, 171, 341, 683.
How many different covering exist on a 2*8 table with 1*2 size dominos?

Fig. 7. a1 = 1, a 2 = 2, a 3 = 3, a 4 = 5 Counting with drawing systematically.

The Place of the Dynamic Programming Concept in the Progression ...

67

If they draw it systematically (seeing the blocks from the right), they can guess the
recursive expressionan=an1+an2 and they check it empirically. The solutions are:1,
2, 3, 5, 8, 13, 21, 34. The solution can be built for any given N with a table filling.
In primary schools the children meet problems with large numbers also, like 1000
points, 2016 numbered cards, 10000 people. In such cases, the obvious idea is instead
of the original task to examine a simplest problem. What happens if the number of
points is 2, 3, 4, ..., the number of cards is 5, 6, 7,, the number of people is 2, 3, 4,?
If any regularity is noticed, they try to verify it empirically and apply it on the original
problem with large numbers. On primary-school-level, formulating and using the hypotheses is enough to solve such problems.
On the other hand, these problems can be implemented on the computer, as a recursive expression or with table filling for larger numbers. The next classical problems are
the first appearance of dynamic programming approach for them:
Robot A robot starts from the top left corner (1,1) of a MxN grid. At each step
the robot can make one of the two choices: move one cell to the right or move one
cell down. How many possible paths are there for the robot to reach the rightbottom corner of the grid?
The robot problem can occur in many variations at grade 7 and 8:
The question is the same, but there are cells in a grid, on which the robot cant
step on (traps).
The question is the same, but there are cells in a grid, on which the robot have
to step on (mandatory fields).
In every cell there are given number of pearls and the question is, what is the
maximum number of pearls the robot can collect on its way.
Mix of traps and pearls.
Staircase You are standing in front of a staircase, which has N stairs. Your goal
is to reach the top. If you are standing on the ith step, you can hop to (i+1)st or
(i+2)nd or (i+3)rd step. Given N, calculate the count of total possible paths for you
to reach Nth stair!
Coin Change You want to make change for given N cents and you have infinite
supply of each of S1, S2, .. , Sm valued coins. How many ways can you make the
change?
Subset sum Detect, if any of the subset from a given set of N non-negative integers sums up to a given value S!
Dice Throw Problem Given N dice, each with m faces, numbered from 1 to m.
Find the number of ways to get sum X! (X is the summation of values shown by
the dices.)
Flooring How many different coverings exist on a 1*N floor with 1*1 and 1*2
parquet pieces? How many different covering exist on 2*N floor with 1*2 parquet
pieces?

68

. Erdsn Nmeth, L. Zsak

Towers How many different, N meters high towers can be built from 2 meters
high blue, 2 meters high yellow and 1 meter high red blocks?
The previous dynamic programming problems should be solved at the primaryschool-level as the analogous math problems: children formulate and use the hypothetical recursive expressions and implement them with table filling, without extensive
argumentation. Mostly they cannot calculate directly the answer, but they can give a
recursive formula and the direction of filling the table, and this way they can solve the
problem. They can solve basic DP problems, without optimization.
On informatics contest the children use basic data structures (integer, boolean, one
and two-dimensional array of integers, simple strings) and basic algorithms can be applied for various problems in various wording. Choosing, selecting, counting, searching, summarizing, selecting maximum/minimum, sorting, separating into two groups,
prime testing are these basic algorithms. Stages of solving tasks are understanding the
problem, choosing the right data structure, selecting right algorithm, implementing and
testing it. In addition to the conservative tasks there are ad-hoc problems where children
can apply basic algorithms creatively. The basic DP problems appear in the regional and
national rounds of competitions.

4.4. Tasks in Lower-Secondary-School-Age


In Hungary and many other countries the children continue to learn combinatorial problems in grades 910 in mathematics lessons, they group and formalise these problems.
During these years, they also meet the idea of mathematical induction, so they can prove
the previously discovered recursive formulae. They learn about sequences and sometimes they give the explicit formulae for recursive expressions. They know the formula

of n! and , they also learn Pascal-triangle. But they do not necessarily know the
relationship between the binomial coeffitients and the Pascal-triangle.
They can discover and solve more complex recursive expressions, sometimes these
functions call each other, like:
How many different covering exist on a 2*N table with 1*2 and 1*1 size dominos?

Fig. 8. a1 = 2, a2 = 7, a3 = 22, a4 = 71 Counting with drawing systematically.

Drawing it systematically is not enough to formulate the recursive expression.


One must analyze possible cases. The result comes with two expressions in simultaneous recursion: dn = an1 + fn1, fn = an1 + dn1, an = 2*an1 + an2 + fn1 + dn1.
After simplification: an = 3*an1 + an2 an3.

The Place of the Dynamic Programming Concept in the Progression ...

69

In this age they learn the basics of graph theory in mathematics, they learn types
of graphs (trees, binary trees, relational matrix), storage of graphs (vertex matrix, edge
matrix, edge list) and algorithms of graphs (breadth first traversal, depth first traversal,
relations) in informatics. They meet recursion again, divide and conquer, backtrack, and
greedy algorithms too, on basic level.
They learn all classic dynamic programming problems, as follows:
Partition problem Divide the set of numbers into two groups, where sum of
each group is same!
Longest Increasing Subsequence Find the length of the longest subsequence
of a given sequence, such that all the elements are sorted in increasing order.
Knapsack Problem A thief robbing a store can carry a maximal weight of W
in his knapsack. There are N items and ith item weighs wi and is worth vi dollars.
What items should the thief take?
Contiguous subsequence with maximum value Find the contiguous array
with the maximum sum in a given an array, containing both positive and negative
integers!
Minimal number of coins for change What is the minimal number of coins, to
make change for a given amount T only coins of values v1, v2, , vn can be used?
These examples can be solved by using recursion with optimization, the right order
of filling the table must be given usually it is not evident. There are a number of variations of these problems, sometimes the difference is merely wording.
Next type of DP problems is game strategy in various formats, like:
Optimal Strategy Consider a row of N coins of values v1, ..., vN, where N is
even. We play a game against an opponent by alternating turns. In each turn, a
player removes either the first or last coin from the row and receives the value
of the coin. Determine the maximum possible amount of money we can definitely
win if we move first?
Basic data structures may be supplemented with string and real. There are a number
of dynamic programming problems with strings, too:
Longest Common Subsequence Find the longest common subsequence of two
strings, where the elements are letters from the two strings and they should be in
the same order!
Longest Common Substring Find the longest common substring of two
strings!
Edit Distance Given two strings and a set of operations Change (C), insert (I)
and delete (D). Find minimum number of operations required to transform one
string into another!
On informatics contest classic dynamic tasks can be in every round, so the contestants
have to be ready to solve it.

70

. Erdsn Nmeth, L. Zsak

4.5. National Olympiads


In grades 1112 contestants prepare for national Olympiads. They know a lot of algorithms, in these years they learn to use advanced data structures, like set, priority queue,
stack, and they implement previously learned algorithms with these data types. While in
previous years they were asked for the existence of the solution or the number of steps
in the solution, now they also have to decrypt the entire path traversal in dynamic programming problems.
Sometimes there are strict memory limits and there is no space for the whole table. In
this case, only the values of those cells have to be stored in memory, which are essential
to the calculation of the next row. During the decryption process the rebuilding of the
table may be as hard and interesting to implement as the original problem.
They learn about combinatorial and geometrical problems.
Within the concept of divide and conquer, recursion or dynamic programming more
complicated expressions should be optimized.
There are advanced DP problems: all possible transitions and dynamic greedy type.
Example of complicated problems:
Balanced Partition There is a set of N integers each in the range 0 ... K. Partition these integers into two subsets such that you minimize |S1 S2|, where S1
and S2 denote the sums of the elements in each of the two subsets!
The dynamic programming concept among strings also leads complicated problems,
like:
Shortest Palindrome Form a shortest palindrome by appending characters at
the start of the given string.
Palindrome Min Cut Find the minimum number of cuts required to separate
the given string into a set of palindromes.
Longest Palindromic Substring Find the longest palindromic substring of a
given string!
Longest Palindromic Subsequence Find the longest palindromic subsequence
of a given string!
The contestants in the upper secondary age want to be computer scientists or engineers, they do not only know the basic algorithms but they can cope with complex tasks.

4.6. Regional and International Olympiads


When you want to prepare for Regional or International Olympiads you have to know
everything about dynamic programming which is included in the textbooks. You have
to solve a huge number of tasks. On Olympiads the solution of tasks are some kind of
creative mixture of known algorithms.
Some examples:
Interval-Scheduling Problem (Greedy and DP Approach) N k-tuples processes
are given with start & end times. Select as many processes as possible such that

The Place of the Dynamic Programming Concept in the Progression ...

71

(I) no two selected processes intersect and (II) at most one process is selected
from each k-tuple!
intersec Complete all tasks given the deadline, so that no task overlap!
Box Stacking You are given a set of N types of rectangular 3-D boxes, where
the i^th box has height h(i), width w(i) and depth d(i). You want to create a stack
of boxes which is as tall as possible, but you can only stack a box on top of another box if the dimensions of the 2-D base of the lower box are each strictly
larger than those of the 2-D base of the higher box. You can rotate a box, any of
the side can be its base. It is also allowable to use multiple instances of the same
type of box.
Counting Boolean Parenthesizations You are given a boolean expression consisting of a string of the symbols true, false, and, or and xor. Count the
number of ways to parenthesize the expression such that it will evaluate to true.
For example, there are 2 ways to parenthesize true and false xor true such that
it evaluates to true. The order is defined only by parentheses.
There are many tasks for practice on the online preparing and contest sites, like
usaco.org, codeforces.com, codechef.com, uva.onlinejudge.org, spoj.pl. If you have met
each type of concept detailed above, the textbook of Halim is a good choice for preparing for IOI.

5. Conclusions
Some antecedents of the dynamic programming concept for example the concept of recursion, might come up in earlier mathematics and informatics studies. If you are aware
of this, introducing DP as a new problem-solving strategy is much easier.
We think, if you want to teach the technique of DP you have to start from a simple
recursion then through memoization and table filling you could end with a real DP for
optimization problems. You could start the whole process in the primary school age and
circularly, returning to it in higher and higher levels your students would be familiar with
this hard concept.
In the upper primary school, the basic DP comes up: a recursive expression implemented with table filling. At the beginning of secondary school, the classic DP programs
continue the sequence: recursive expressions with optimization and at implementation
the right order of table filling need to be thought of. In upper secondary school, the
children can be familiar used with advanced types of DP: all of the previous problems
with the retrieval of the way, how the optimal solution is built up, dynamic greedy type
and the type, when you have to keep track of all possible transition states. Preparing for
Olympiads, the students need everything from textbooks and the combination of other
types of approaches.
Finally, it would not be magic for the contestants, just a useful problem-solving
strategy.

72

. Erdsn Nmeth, L. Zsak

References
BebrasInternational Contest on Informatics and Computer Fluency (20072015). http://bebras.org
http://www.beaver-comp.org.uk/; http://informatik-biber.de/archiv/
Bebis, G. (2007). CS477/677 Analysis of Algorithms.
http://www.cse.unr.edu/~bebis/CS477/
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C. (2001). Introduction to Algorithms. MIT Press, 2nd edition.
Dagien, V., Stupurien, G. (2016). Bebras a sustainable community building model for the concept based
learning of informatics and computational thinking. Informatics in Education, 15(1), 2544.
Dasgupta, S., Papadimitriou, C.H., Vazirani, U.V. (2006). Algorithms. McGraw-Hill.
Dreyfus, S. (2002). Richard Bellman on the birth of dynamic programming. Operations Research, INFORM.
50(1), 4851.
Erds, G. (2010). A rekurzv mdszer. In: Magas Szint Matematikai Tehetsggondozs Konferencia, ZALAMAT. 2032.
Foriek, M. (2015). Towards a better way to teach dynamic programming. Olympiads in Informatics, 9, 4555.
Gupta, N. (2009). Introduction to Algorithms.
http://www.curriki.org/oer/Introduction-to-Algorithms/
Halim, S., Halim, F. (2014). Competitive Programming 3. The New Lower Bound of Programming Contests.
http://cpbook.net/
Horvth, Gy. (2004). A programozsi versenyek szerepe az oktatsban. In: INFORA Konferencia.
http://www.infoera.hu/infoera2004/eaok/horvathgyula.pdf
Kleinberg, J., Tardos, . (2006). Algorithm Design. Addison-Wesley.
Sedgewick, R., Wayne, K. (2011). Algorithms, Fourth Edition. Addison-Wesley.
Skiena, S.S. (2008). The Algorithm Design Manual. Springer-Verlag, 2nd edition.
Steinhardt, J. (2008). Advanced Dynamic Programming Techniques.
https://activities.tjhsst.edu/sct/lectures/0708/dpadvanced.pdf

. Erdsn Nmeth teaches mathematics and informatics at Batthyny


Lajos High School in Nagykanizsa. A lot of her students are in the final
rounds of the national programming competitions, some on CEOI and
IOI. She is a Ph.D. student in the Doctoral School of Faculty of Informatics, Etvs Lornd University in Hungary. Her current research
interest is teaching computer science for talented pupils in primary and
secondary school.
L. Zsak Dr. is a professor at Department of Media & Educational
Informatics, Faculty of Informatics, Etvs Lornd University in Hungary. Since 1990 he has been involved in organizing of programming
competitions in Hungary, including the CEOI. He has been a deputy
leader for the Hungarian team at International Olympiads in Informatics since 1989. His research interest includes teaching algorithms and
data structures; didactics of informatics; methodology of programming
in education; teaching programming languages; talent management.
He has authored more than 68 vocational and textbooks, some 200
technical papers and conference presentations.

Olympiads in Informatics, 2016, Vol. 10, 7385


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.05

73

Watch them Fight! Creativity Task Tournaments


of the Swiss Olympiad in Informatics
Samuel GRTTER, Daniel GRAF, Benjamin SCHMID
Swiss Olympiad in Informatics

e-mail: {samuel,daniel,benjamin}@soi.ch
Abstract. As part of the qualification process for the Swiss Olympiad in Informatics, the contestants are each year confronted with one Creativity Task. Unlike typical problems in programming competitions, creativity tasks usually do not have an optimal solution, and are often
adaptations of popular board or computer games. After receiving all submissions, a tournament is
organized, where the students can watch how their programs play interactively against each other,
and points are awarded to the authors according to the tournament ranking.
We present and discuss this task format in general, as well as the specific creativity tasks of
the past 10 years, accompanied by an online archive of the task descriptions, sample solutions and
game servers.
Moreover, we describe our task selection process and criteria, the task creation process, and
the experience gained and best practices established in the past years.
Finally, we present the many advantages of this task format, showing why we think it is a
refreshing alternative to the common IOI-style tasks given in most national selection rounds.
Keywords: creativity tasks, interactive tasks, heuristics, programming competition, board games,
artificial intelligence contest, tournaments, task visualization.

1. Introduction
During the first round of the Swiss Olympiad in Informatics (SOI), the students have
two months to solve a set of tasks at home and submit them on the SOI website. There
are practical and theoretical tasks, and one creativity task. This paper is about the creativity tasks.
Contrary to typical tasks in programming competitions, the creativity tasks are usually designed in such a way that there is no optimal solution, or that the optimal solutions are not efficient enough. The creativity tasks are often adaptations of popular
board or computer games, and the game can be played with two or more players. The
participants task is to write a program able to play the game. We will refer to such
programs as bots.
An interesting aspect of this task format is that the participants bots can play and
compete against each other.

74

S. Grtter, D. Graf, B. Schmid

At the start of each years first round, the following material for the creativity task is
published on the SOI website:
The task description, describing the rules of the game and its parameters. Depending on the game, these could include, for instance, width and height of the
playing field, or a map of the playing field, the number of players, the initial
amount of money/food of each player, etc. The task description also specifies
the communication protocol between the bots and the game server (see below),
which defines how the bots have to communicate their actions and how they are
informed about the other bots actions. All communication is done via standard
input/output.
A game server, a program written by the task authors, which launches the bots,
communicates with them according to the protocol and keeps track of the game
state. It informs the bots about all the relevant changes and prints a log of each
action and state change. The server also acts as a judge that can terminate bots
that drop out of the game or take too long to answer. If the interaction protocol is
easy to read, the game server can also allow for human players that type in their
commands interactively. This way, the participants can play against their own
bots by hand.
Some sample bots in various programming languages. These bots follow all the
rules of the protocol, but they just pick a random move in every step. The participants can base their solutions on these sample bots to quickly learn how to
implement the protocol and input/output. Moreover, they can evaluate their bots
by letting them play against the sample bots.
A visualization, which reads the log produced by the game server, and displays a
graphical animation of the game. For some of our tasks, the game server already
provides a rudimentary text-based visualization of the game.
After the end of the first round of the SOI, the organizers let the submitted bots
compete against each other in a large number of games covering many different configurations, to make sure that the obtained results are representative and random decisions
average out well enough. The results of all these games are then aggregated into a final
score for each participant.
Between the first and the second round of the SOI, all participants are invited to an
event called SOI-Day consisting of task discussions, talks and presentations. At this
event, a shortened version of the the creativity task tournament is presented as if it was
a live tournament, and the participants can thrill while watching their bots compete
against the others.

2. Ten Years of Creativity Tasks


In this section, we give a brief presentation of each creativity task of the past ten years.
We omit details such as the communication protocols, and refer the reader to the online
task archive (http://creativity.soi.ch) for the full task descriptions.

Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

75

2.1. Connect Five (2007)


Task description On a 20 20 grid, two players (black and white) alternate in placing a
stone of their color on an empty square. As soon as a player succeeds in placing 5 stones
in a row (horizontally, vertically or diagonally), he wins.
Note that unlike the game sold under the name Connect Four, the stones do not
fall down in their column, but stay exactly where they were placed.
Discussion This variant of the game is also known under the name Gomoku, and appeared at the International Computer Games Associations Computer Olympiad in 1989,
1990, 1991 and 1992.1

2.2. Fight of the Ant Populations (2008)


Task description On a grid with obstacles, multiple ant colonies are fighting against
each other. Each player controls all ants of a colony. In every turn, the player sees the
7 7 neighborhood of each of his ants and can move them individually to an adjacent
tile. Some tiles contain food, others contain ants or the hill of the enemy. Collecting food
and carrying it back to the own hill allows the colony to grow. If an ant attacks another
ant both die. If an ant reaches an adversarial hill, three random ants of that colony die.
Which colony survives the longest?
Discussion This game allows for a huge variety in strategies. Some submissions assigned different jobs to the ants, for instance: explorers that go to unknown territory,
workers that collect the closest food, guards that stay near the hill and warriors that try
to reach the hill of the enemy.

2.3. Grand Theft Cake (Portal Maze) (2009)


Task description The players are searching for a big cake in an unknown, polygonal
maze with walls all around them. They have a handheld portal device that allows them
to teleport from A to B instantly. They can walk around with a speed of 1 meter per
second. In 0.1 seconds, they can look in a direction to learn how far away the wall is.
It takes 5 seconds to shoot a portal in a direction (either of type A or B). The cake is a
circle of one meter diameter. The goal is to find the cake and return to the starting position as quickly as possible.
Discussion The submitted solutions made creative use of the portal. Some just used it
to return to the start quickly, others repeatedly used it as a shortcut throughout the entire
search for the cake.
1

http://www.game-ai-forum.org/icga-tournaments/game.php?id=30

76

S. Grtter, D. Graf, B. Schmid

2.4. Tanks (2010)


Task description Each player controls a tank, which can move on a line and fire one
missile per round. The tanks can use different weapons, which are specified by their
range, their impact radius, and their damage points. The tanks have an unlimited number
of missiles of each weapon. When a missile hits a position, the damage points of all
tanks within the impact radius increases by the number of damage points of the weapon,
and tanks reaching a predefined number of damage points die. Moving around costs fuel,
and the fuel is limited. The last surviving tank wins.
Discussion Most submissions implemented some simple ad hoc heuristics. The winning
solution was 285 lines long and in each round, it chose the weapon and target position
which would cause the highest total damage to all opponents, supposing that they would
not move. If there was a tie between several possibilities, the one with the biggest impact
radius was chosen.

2.5. Multisnake (2011)


Task description Multisnake is a multi-player version of the popular computer game
called snake (Fig. 1). It is played on a rectangular grid which contains some obstacles.
Each player controls a snake, and in each turn, all snakes move simultaneously by one
step. When a snake moves onto a field occupied by an obstacle or by a snake, it dies.
The winner is the last surviving snake. Some tiles contain a black or white ball. When a
snake eats a white ball, it grows by one, and when it eats a black ball, it shrinks by one.
To enforce termination of the game, all snakes grow by one each T turns, where T is a
small positive integer.
Discussion The winning solution was 1005 lines long, implemented a complex scoring
function for possible states, and explored them recursively.

Fig. 1. Multisnake.

contestants are immediately fighting against each other.


Finally, we believe that creativity tasks are also a way to train for the newer, les
standard IOI tasks where heuristical solutions are required. Examples of such c
IOI tasks include Languages and Maze from IOI 2010, Odometer from IOI 201
Watch them Fight!
TaskIOI
Tournaments
Art Creativity
Class from
2013. of the Swiss Olympiad in Informatics 77
4.4. Disadvantages of this Task Format
2.6. Find the Anthill (2012)
It often proved challenging to find tasks that beginners can easily get started wi
still leave a lot of options for the creativity of more advanced students. This hig
Task description In
this second
task,small
the story
was more
peaceful:
each ant for many of th
initial
hurdleant-themed
lead to fairly
numbers
of serious
submissions
just has to find the presented
way back to
its
own
ant
hill
(Fig.
2).
The
big
difference
is
that this
tasks. From an organizer's point of view, creativity
tasks take signific
time each ant is controlled
by
a
separate
instance
of
the
participants
submission.
So the
more time to prepare and grade than regular tasks.

program controlling5.a Conclusion


single ant does not know where the other ants of its colony are,
unless they are in its
view.
7 field ofcreativity
In7summary,
tasks proved to be a beneficial addition to the types of
Like in nature, there is a distributed way of communication though: scents. The ants can
algorithmic challenges given in the first national round of the Swiss Olympiad
place one out of 256 different scents on their current tile and they can sense the scents
Informatics.
that other ants (of their own or of other colonies) put there. So if one ant sees the hill, it
We provide the full description and supplementary material for the presented ta
can leave hints for its colleagues.

online at http://creativity.soi.ch and we want to encourage other deleg

Discussion Successful
submissions
use of
thelook
scentforward
hints to to
share
knowl-about their exper
experiment
withmade
suchcreative
task types
and
learning
edge between the ants.
Some
even
tried
to
learn
and
imitate
the
marking
patterns
of the
Acknowledgments
opponents to mess We
withwould
it and cause
confusion.
like to thank all the volunteers of the Swiss Olympiad in Informatics

created, prepared and graded these tasks over the years.

References

2.7. Who wants to be a billionaire (2013)


Aigner, M., Fromme, M. (1984). A game of cops and robbers. Discrete Applied
Mathematics, 8(1), 112.
Task description The
task B.
is (2008).
to write Breaking
a bot which
interactively
multiple Informatics Oly
Burton,
thecan
routine:
events answer
to complement
choice questions with
four
possible
answers,
using
Wikipedia
articles
as
a
knowledge
training. Olympiads in Informatics, 2, 515.
base. For each question,
theM.
bot(2013).
is allowed
to consult
up to 25 articles
on the English
Foriek,
Pushing
the boundary
of programming
contests. Olympiads
Wikipedia. To do so,
the
bot
has
to
provide
a
query
string
to
the
game
server,
and the
Informatics, 7, 2335.
game server will look
up the article
on Wikipedia
(or inand
its cache),
and feed
a plain
text
Gardner,
M. (1973)
Sim, Chomp
Race Track:
new
game
for the intelligent
version to the bot. just for Lady Luck). Scientific American, 228(1), 108115.
Verhoeff,
T.based
(2009).
years search
of IOIcombined
competition
Olympiads in Informati
Discussion Most solutions
were
on 20
keyword
withtasks.
some strategy
149166.
to avoid frequent words
which do not carry any meaning. The submitted bots would not
have become billionaires, but the best was still twice as good as a random bot (which
would have scored 14 of the points).

Fig. 2. Find the Anthill.

78

S. Grtter, D. Graf, B. Schmid

There were 11 submissions, and for the tournament, they were fed a total of 547
questions. Table 1 shows the ranking and their percentage of correct answers. Note that
the primary ranking criterion was whether they were compilable and never crashed, and
the number of correct answers was only the secondary criterion.

2.8. Cops and Robbers (Scotland Yard) (2014)


Task description Some cops are hunting a robber in a city whose streets and junctions
are given as an undirected connected graph (Fig. 3). Initially, the cops and robbers are
positioned on distinct junctions (nodes in the graph), and in each round, the robber and
all cops move along an edge of the graph. As soon as a cop moves onto the same node
as the robber, the cops win, and if this never happens during a predefined number of
rounds, the robber wins.
One bot controls the robber, and another bot controls all cops. Every bot must be
able to play both roles. At any time, the bots know the entire graph and the positions of
all agents.
Discussion This is a classic problem in graph theory and we refer to Aigner and Fromme
for a nice introduction (Aigner and Fromme, 1984).
The participants mostly implemented sophisticated scoring functions that would for
instance weigh the distance between the cops and the robbers against the number of possible escape routes.
Table 1
The ranking and their percentage of correct answers
rank

% correct
behavior

50% 37% 35%


never crashed

45% 36% 28%


sometimes crashed

10

27%

2%

0%

N/A N/A
did not compile

Fig. 3. Cops and Robbers.

10

Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

79

2.9. Diamond Auction (2015)


Task description The players are at an auction bidding for diamonds. Each player starts
with the same amount of gold and for each diamond everyone can bid an amount of his
choosing. The highest bid gets the diamond, but all offered gold has to be paid. The goal
is to maximize the number of bought diamonds using only the given amount of gold. To
allow for more interesting strategies, there are several games played with the same players without restarting the participants programs. This way, they can learn and exploit
each others strategies.
Discussion Being a very simple game with a simple protocol, we had many submissions
for this task. Many of them implemented a random strategy sometimes even worse than
our sample bots. Most of the more successful solutions tried to imitate the opponent or
to predict the next move. The following graph (Fig. 4) shows the last game of the final,
the lines showing the bids of the two players for the different rounds. Although the bids
seem random the players are able to predict each others bid and bid just a little bit more.
This results in a very clever use of the available gold.

2.10. Vector Car Racing (2016)


Task description Each player controls a car and in each round he can change his velocity vector by at most one in both directions. The game is played on a grid (i.e. a graph
paper) with a start, a goal, some checkpoints and some walls enclosing a racetrack. The
goal is to visit each checkpoint at least once and be the first to reach the goal. Should a
player drive into the wall (e.g. if he didnt slow down early enough in a turn) he will be
reset to the last visited checkpoint. To allow for some interaction, we added two items
that can manipulate the velocity vector of other players.
Discussion This game is a well known pen and paper game and goes back to Jrg Nievergelt. It became widely known by an article in Martin Gardners column in the Scientific American (Gardner, 1973).

Fig. 4. Diamond Auction (the graph shows the last game of the final).

80

S. Grtter, D. Graf, B. Schmid

The submissions fell into one of two categories: sophisticated algorithms beating
human players easily (3 submissions) or being barely able to play the game (4 submissions). One example from the second category used DFS to determine the shortest
path resulting in some of the longest possible paths.
The winning submission consists of 1741 lines of code using a wide range of algorithms. On small maps it uses a four dimensional BFS (location and velocity) to find
the optimal solution. On bigger maps, a heuristic is used to improve the runtime of this
algorithm and only paths between two checkpoints are calculated. To find the best order
of checkpoints it uses some more heuristics to find a good approximations for the traveling salesman problem.

2.11. Statistics
Table 2 shows our observed participation rates in the last ten years. Given the bonus-like
character of the creativity tasks, participation rates in the past years fluctuated heavily.
Usually, only students with enough time (and interest) left after solving the five classical
problems tackled the creativity task. Tasks with a very simple interface (like the diamond auction in 2015) seem to have drawn additional interest, probably because writing
a first solution was easily possible within an hour, also for beginners.
(4 submissions). One example from the second category used DFS to determine
the shortest path resulting in some of the longest possible paths.
The winning submission
3. Implementation
Details consists of 1741 lines of code using a wide range of
algorithms. On small maps it uses a four dimensional BFS (location and velocity)
to nd the optimal solution. On bigger maps, a heuristic is used to improve the
runtime
thisSelection
algorithm
and
only paths
between two checkpoints are calculated.
3.1.
Our of
Task
and
Creation
Process
To nd the best order of checkpoints it uses some more heuristics to nd a good
approximations for the traveling salesman problem.
The SOI is organized by a team of approximately twenty people, most of whom are
former participants and now university students. Each year when the preparations of the
2.11round
Statistics
first
of the SOI start, they discuss a few proposals for the creativity task on their
internal mailing list. Once the task is chosen, two to three organizers are selected to
write
the detailed
description
and implement
the game
server
and last
the visualization.
The table
belowtask
shows
our observed
participation
rates
in the
ten years.
A
few more
organizers character
proofread the
taskcreativity
description
and write
sample bots
in as
Given
the bonus-like
of the
tasks,
participation
rates
in many
the
languages
possible. heavily. Usually, only students with enough time (and
past yearsas uctuated
interest) left after solving the ve classical problems tackled the creativity task.
Tasks with a very simple interface (like the diamond auction in 2015) seem to
have drawn additional interest, probably
Table 2because writing a rst solution was
easily possible within an hour,
also
for
Participation ratesbeginners.
in the last ten years
year

2008 2009 2010 2011


2012 2013 2014 2015 2016
year 20072007
2008 2009 2010 2011 2012
2013 2014 2015 2016
c5
maze tanks
tanks snake
snake ants
ants quiz
racerace
tasktask
c5
antsantsmaze
quiz c&r
c&r
creativity
17
N/A 4 4 6 6 2 2 1010 1111
25
77
creativity
17
N/A
99
25
total
21
31
35
40
48
29
29
28
52
72
total
21
31
35
40
48
29
29
28
52
72

3
3.1

Implementation Details
Our Task Selection and Creation Process

Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

81

The organizers of the creativity task are usually people who have successfully taken
part in the creativity task a few years before when they were participants, and they are
supported by older organizers who prepared the creativity task a few times before. This
ensures a good knowledge transfer, which leads to good creativity tasks, even though
this task format is more challenging for task creators than ordinary tasks and even though
every year, many organizers join and leave the team.

3.2. Evaluating the Submissions


After the end of the first round of the SOI, the organizers review and compile all submissions for the creativity task, and then run a large number of games, covering a representative selection of different game parameter and player combinations. The results of all
these games are then aggregated into a final score for each participant, and points for the
creativity task are awarded as follows:
A bot that follows the protocol and is capable of playing the game without violating
any rules is awarded a predefined percentage p of the points, usually between 30%
and 50%, depending on how difficult the task is. We also look at the source code to
see if it witnesses more effort than just copying one of the provided sample bots.
The rest of the points are awarded according to the aggregated score described
above, in such a way that the participant ranked last gets p points, and the participant ranked first gets full score.
If the bot contains minor bugs, such that it can still play in most games, but sometimes crashes, runs into an infinite loop, or violates the rules, some points are deducted.
This grading scheme ensures that every effort to write a program for this task is rewarded, even if it ranks last, which hopefully encourages beginners to tackle this task.

3.3. Technical Considerations


Ease of running the game server and the visualization It is crucial that all participants
are able to run the game server on their own computers.2 However, the game server
needs to be able to invoke other programs (the bots) and read from their standard output
and write to their standard input, a feature which is hard to get operating system independent. And even if the game server works on all major operating systems, the instructions
on how to install the dependencies, compile and run it might look so long and complicated that beginners are quickly scared off. For the visualization, it can even get worse,
if specific graphics libraries have to be installed and linked.
2

We cannot provide an online game server instead, because in the first round of the SOI, no participants
should be disadvantaged because they cannot use their favorite programming language. This would mean
that we would have to support a very large number of programming languages, and moreover, it would
require a big effort for the sandboxing.

82

S. Grtter, D. Graf, B. Schmid

In our experience, implementing the game server in Java, which is available on all
platforms, seems to be the best solution. But even getting a Java game server to run was
a bit challenging for some participants, because some could only install Java 6 (instead
of newer versions) on their system, while others did not know how to specify the paths
to the bots as command line arguments, etc. But we could always help them by email
support or through our forum. What we do not know, however, is how many people did
not succeed in getting the server to run, but did not ask for help.
For the visualization, the two best solutions seem to be either to integrate the visualization in the Java game server, or to implement it as an HTML5/JavaScript page,
where one can paste the log of the game server, and then watch the visualization. An
advantage of the latter is that it only requires a web browser, which is available on every
computer, so we can provide some sample game logs, so that the participants can watch
some games before even starting to implement their own solution and to bother getting
the game server to run.
Fraud Detection The grading of the creativity task is not fully automated on purpose.
The submissions are compiled manually to check for compatibility issues and the source
code is read to get an idea of the participants solution and to check that all the rules are
followed. Given the small number of participants, this is feasible and also eliminates the
need for a separate fraud detection or sandboxing of the submitted programs.

4. Discussion
4.1. Task Selection Criteria
We now present our criteria for the selection of the creativity task. This is more a collection of useful arguments that came up in past discussions rather than an ultimate list.
Interactivity: It should be interactive, and interaction should not only happen between the game server and the bots, but also between the bots, i.e. the possible
moves of a player should depend on the actions that the other players took before.
This is mostly to make the task more fun and different from the standard tasks, but
it is not strictly necessary. For instance, the Grand Theft Cake task (section 2.3),
or the Who wants to be a billionare? task (section 2.7) do not have any interaction
between the players, and still were successful creativity tasks. In the case of the
Vector Car Racing task (section 2.10), however, some special effects were added
to the traditional game to make it interactive, and to increase the size of the search
space that optimal solutions would have to explore.
Hardness: There should be no optimal solution, or optimal solutions should be too
expensive to calculate.
Flat learning curve: The task should be simple, with few, easy to understand
rules, so that it is suitable for beginners, but it should also offer many interesting
options for advanced participants.

Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

83

Novelty: The task should not be too standard to make sure one cannot just copy
and adapt a standard solution found on the internet. For instance, chess or Nine
Mens Morris were proposed in the past years, but not chosen for this reason.
Continuous Complexity Curve: There should be a continuous spectrum of imagineable solutions between straightforward random bots and very sophisticated solutions.
Plethora of solutions: There should be many different solutions that could work
reasonably well and are feasible to implement. For instance, for some proposed
tasks, it was feared that applying a standard minimax algorithm would be almost
the only reasonable solution, and these tasks were thus not chosen.
Manual playing: It is a plus if the game can be played by hand, such as Multisnake
(section 2.5) or Vector Car Racing (section 2.10), so that the participants can compare their bots to their own intuitive playing style.
Visualizability: A good task should allow for an appealing way of watching the
interaction between the bots and giving a dramatic view on the progress of the
game.

4.2. Similar Task and Contest Types


The IOI and other programming contest are always experimenting with new, less algorithmic task types. We refer to Verhoeff (Verhoeff, 2009) for an overview of classical,
algorithmic IOI tasks. Foriek (Foriek, 2013) gives an overview of the programming
contest landscape. He also presents some tasks from the IPSC and Slovak national competitions whose goal is different from just finding the fastest algorithm. Some contests
entirely focus on hard optimization problems like Topcoders Marathon matches and
Googles Hash Code and other contests feature tournaments of competing bots for interactive problems like the AI Challenge or the Computer Olympiad.
Creativity-like tasks are also mentioned as game-playing events by Burton in (Burton, 2008), where many interesting suggestions for out-of-the-ordinary activities in
Olympiad training camps are proposed.

4.3. Advantages of this Task Format


In our opinion, creativity tasks offer a number of unique possibilities. These nonstandard
tasks can keep the participants busy for many weeks. They can try out all kinds of crazy
algorithms and even the best ones are never really done. But also students with limited
time can participate with some quick extension of the provided random bot.
The visualization of these tasks are ideal to be shown on a large screen during an
award ceremony as parents, friends and teachers can really see what the contestants
were doing. As related board and computer games are well-known, an audience that is
not familiar with specifics of the algorithmic challenge can also appreciate the results.

84

S. Grtter, D. Graf, B. Schmid

The tournaments are fun to watch as the interaction between the bots suggests that the
contestants are immediately fighting against each other.
Finally, we believe that creativity tasks are also a way to train for the newer, lessstandard IOI tasks where heuristical solutions are required. Examples of such creative
IOI tasks include Languages and Maze from IOI 2010, Odometer from IOI 2012 and Art
Class from IOI 2013.

4.4. Disadvantages of this Task Format


It often proved challenging to find tasks that beginners can easily get started with but
still leave a lot of options for the creativity of more advanced students. This higher initial
hurdle lead to fairly small numbers of serious submissions for many of the presented
tasks. From an organizers point of view, creativity tasks take significantly more time to
prepare and grade than regular tasks.

5. Conclusion
In summary, creativity tasks proved to be a beneficial addition to the types of algorithmic
challenges given in the first national round of the Swiss Olympiad in Informatics.
We provide the full description and supplementary material for the presented tasks
online at http://creativity.soi.ch and we want to encourage other delegations
to experiment with such task types and look forward to learning about their experiences.

Acknowledgments
We would like to thank all the volunteers of the Swiss Olympiad in Informatics who created, prepared and graded these tasks over the years.

References
Aigner, M., Fromme, M. (1984). A game of cops and robbers. Discrete Applied Mathematics, 8(1), 112.
Burton, B. (2008). Breaking the routine: events to complement Informatics Olympiad training. Olympiads in
Informatics, 2, 515.
Foriek, M. (2013). Pushing the boundary of programming contests. Olympiads in Informatics, 7, 2335.
Gardner, M. (1973) Sim, Chomp and Race Track: new game for the intelligent (and not just for Lady Luck).
Scientific American, 228(1), 108115.
Verhoeff, T. (2009). 20 years of IOI competition tasks. Olympiads in Informatics, 3, 149166.

Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

85

S. Grtter was a participant at CEOI 2009 and IOI 2010, and has
helped with the organization of the Swiss Olympiad in Informatics
since 2011. He was deputy leader of the Swiss team at IOI 2013.
He holds a BSc in Computer Science from Ecole Polytechnique
Fdrale de Lausanne (EPFL), where he is currently pursuing his MSc
and working at the Scala Lab under the supervision of Prof Martin
Odersky.
His research interests are logic, formal languages, type systems and
compilers.
D. Graf participated at CEOI 2009 and IOI 2009 (bronze) and returned
to IOI as the delegation leader of the Swiss team in 2012, 2014 and
2015. He volunteers for the Swiss Olympiad in Informatics since 2010
and is its president since 2011.
He holds a MSc in Computer Science from the Swiss Federal Institute of Technology in Zurich (ETHZ), where he is currently pursuing
his PhD in the group for Algorithms, Data Structures, and Applications
of Prof. Peter Widmayer.
B. Schmid participated at IOI 2013, IOI 2014 (bronze) and CEOI 2013
(bronze). Since 2015 he helps organizing the Swiss Olympiad in Informatics.
He is currently pursuing a BSc in Computer Science from ETH
Zurich.

Olympiads in Informatics, 2016, Vol. 10, 8798


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.06

87

Understanding Unsolvable Problem


Jonathan Irvin GUNAWAN
Undergraduate Student
School of Computing, National University of Singapore
Computing 1, 13 Computing Drive, Singapore 117417
e-mail: jonathan.irvin@yahoo.com
Abstract. In recent IOIs, there are several problems that seem unsolvable, until we realise that
there is a special case to the problem that makes it tractable. In IOI 2014, the problem Friend
appears to be a standard NP-hard Maximum Independent Set problem. However, the graph is generated in a very special way, hence there is a way to solve the problem in polynomial time. There
were several contestants who didnt identify the special case in this problem, and hence were stuck
at the problem. In this paper, we will study a well-known technique called reduction to show that
a problem we are currently tackling is intractable. In addition, we introduce techniques to identify
special cases such that contestants will be prepared to tackle these problems.
Keywords: special case, unsolvable, NP-hard.

1. Introduction
The problem Friend in IOI 2014 required contestants to find a set of vertices with maximum total weight, such that no two vertices in the set are sharing a common edge. This
is a classical Weighted Maximum Independent Set problem. We can show that Weighted Maximum Independent Set problem is NP-hard by reduction from 3-SAT (Cormen
etal., 2009). Since the formulation of NP-completeness 4 decades ago, no one has been
able to propose a solution to any NP-hard problem in polynomial time. Clearly, it is not
expected that a high school student can solve the problem in 5 hours. None of the Indonesian IOI 2014 team solved this problem during the contest. After returning from the
competition, I asked the Indonesian team about this problem. None of the team members
were aware of the fact that Maximum Independent Set is an NP-hard problem, and thus
were stuck trying to solve a general Maximum Independent Set problem.
A similar problem also occurred in IOI 2008. The problem Island required contestants to find a longest path in a graph with 1,000,000 vertices. The longest path problem
is a classic NP-hard problem which can be reduced from the Hamiltonian path problem.
If a contestant is not aware that the longest path problem is difficult to solve, the contestant may spend a lot of his/her time just to tackle the general longest path problem,
without realising that there is a special case to the given graph.

88

J.I. Gunawan

Generally, some contestants spend too much thinking time trying to solve something
that is believed to be unsolvable. If only they realise that their attempt is intractable,
they may try a different approach and find a special case of this problem. In section 2
of this paper, we will introduce a classic reduction technique often used in theoretical
computer science research. In the context of competitive programming, we may find out
that a problem which we are attempting is unlikely to be solvable. After realizing that
a problem is intractable, we are going to discuss how to proceed to solve the problem
in section 3. Finally, in section 4 we will take a look at some common special cases in
competitive programming that can be used to solve these kind of problems.

Fig. 1. The result of Indonesian team in IOI 2014, taken from http://stats.ioinformatics.org. The red squared column highlights the Friend problem.

Fig. 2. IOI 2014 tasks statistics, taken from http://stats.ioinformatics.org. Friend


problem is the second least accepted problem in IOI 2014. It may be because some contestants (at least all the Indonesians) were stuck at trying to solve a general case of Maximum
Independent Set.

Fig. 3. The result of Indonesian team in IOI 2008, taken from http://stats.ioinformatics.org. The red squared column highlights the Island problem.

Understanding Unsolvable Problem

89

2. Identifying Intractability of a Problem through Reduction

22 Identifying
Identifying
Intractability
Intractability
of
aaRedu
Pro
Pro
22 Identifying
of
aaProblem
through
Reduc
IdentifyingIntractability
Intractability
of
Problem
through
2 Identifying
Intractability
of aof
Problem
2
Identifying
Intractability
ofR
entifying
Intractability
of
a
Problem
through
Reduction
2
2
Identifying
Identifying
Intractability
Intractability
of
of
a
a
Problem
Problem
through
through
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
m
through
Reduction
actability
of
a
Problem
through
Reduction
ifying
Intractability
of
a Problem
through
Reduction
2 through
Identifying
Intractability
ofthe
aproblem
Problem
through
R
Intractability
of
a
Problem
through
Reduction
of
a
Problem
Reduction
We
We
would
would
like
like
to
to
know
know
that
that
the
problem
that
that
we
we
are
are
attempting
attempting
isis u
immediate
solution.
The
most
way
toare
apply
athe
well-known
technique
called
rough Reduction
solut
We
would
totoknow
that
the
problem
that
attempting
is
unlikely
to
have
an
immediate
soluti
We
wouldlike
like
know
that
thecommon
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solu
We
would
like
toiswe
know
that
problem
that
we
are
attempting
is
unlikely
We that
would
like
to
thatisisthe
problem
thatcalled
we
are
att
actability
of
awould
Problem
doto
like
to
know
that
the
problem
that
we
are
attempting
is Reduction
unlikely
to
have
anknow
immediate
solution.
We
We
would
would
like
like
to
know
know
that
that
the
problem
problem
that
we
are
are
attempting
attempting
unlikely
unlikely
to
toThe
have
have
an
an
immedi
immed
have
anwe
immediate
The
oblem
that
areproblem
attempting
is
unlikely
tothrough
an
immediate
solution.
The
most
most
common
common
way
way
iswe
iscalled
to
to
apply
apply
aa and
well-known
well-known
technique
technique
called
redu
reduction.
Suppose
we
know
that
problem
X
is
impossible
to
solve,
we
also
know
know
that
the
that
we
attempting
isthe
unlikely
to
have
an
immediate
solution.
The
most
common
way
is
toto
apply
ahave
technique
reduction.
Suppose
we
know
that
prob
We solution.
like
know
that
the
problem
that
are
is
unlikely
to
have
an
immedia
most
common
way
isare
to
apply
awell-known
well-known
technique
called
reduction.
Suppose
we
know
thatreduc
pro
most
common
way
is
to we
apply
aattempting
well-known
technique
called
reduction.

at
the
problem
that
we
are
attempting
isSuppose
unlikely
to have
have
an
immediate
solution.
The
tanthe
problem
that
we
attempting
is
unlikely
to
an
immediate
solution.
The
most
common
isknow
apply
a well-known
technique
attempting
is
unlikely
to
have
anproblem
immediate
solution.
1 to
mmon
isknow
to
aare
well-known
technique
called
reduction.
Suppose
we
know
problem
X isproblem
immediate
solution.
The
most
most
common
common
way
way
is
is
to
to
apply
apply
aknow
aThe
well-known
well-known
technique
technique
called
called
reduction.
reduction.
we
we know
know
Suppose
we
that
problem
X
is
well-known
technique
called
reduction.
we
that
problem
Xway
isX
impossible
impossible
to
to
solve,
solve,
and
we
we
also
also
that
that
we
we
can
solve
solve
problem
XX
b.tI
11 1by
that
we
can
solve
X
by
using
problem
Y
asand
a black-box
If
we
can
solve
way
isaway
to
apply
aapply
well-known
technique
called
reduction.
Suppose
we
know
problem
Xcan
isSuppose
impossible
toto
solve,
and
we
know
that
we
can
solve
problem
by
using
problem
YSuppose
asasawe
.th
most
common
way
isto
tohave
apply
ato
well-known
technique
called
reduction.
Suppose
we
impossible
solve,
and
wealso
also
know
that
we
can
solve
problem
Xthat
by.X
using
problem
Y
ablack-box
black-box
impossible
solve,
and
we
also
know
that
we
can
solve
problem
X know
bysolve
using
apply
well-known
technique
called
reduction.
Suppose
we
know
that
problem
X
is
pply
a
well-known
technique
called
reduction.
Suppose
we
know
that
problem
is
impossible
to
solve,
and
we
also
know
that
can
p
1
blem
that
we
are
attempting
is
unlikely
an
immediate
solution.
The
e
called
reduction.
Suppose
we
know
that
problem
X
is
1
1
elve,
tothat
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
we
know
that
problem
X
is
impossible
impossible
to
to
solve,
solve,
and
and
we
we
also
also
know
know
that
that
we
we
can
can
solve
solve
problem
problem
X
X
by
by
using
using
problem
problem
Y
Y
as
as
a
a
blac
bla
1Y
problem
Y
as
a
black-box
.
If
we
can
ow
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
solve
solve
problem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
X
as
as
well.
well.
Therefore,
Therefore,
pro
pr
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
is
also
imand
we that
also
know
that
we
can
solve
problem
X
by
using
problem
Ysolve
as
a11 .problem
black-box
we
can
solve
problem
Y,
then
we
can
solve
problem
XY
as
well.
Therefore,
problem
YIf
also
impossible
to
impossible
toassolve,
and
we1problem
also
know
that
we
can
Xcan
using
problem
Y as
as
asolve.
black
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Yis
is
also
impossible
to
solve
solve
Y,
then
we
can
solve
problem
X.by
as
well.
Therefore,
problem
eeY
also
know
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
If
we
can
also
know
that
we
can
solve
problem
X
by
using
problem
as
a
black-box
.
If
we
can
solve
problem
Y,
then
we
solve
problem
X
well.
T
ell-known
technique
called
reduction.
Suppose
we
know
that
problem
X
is
1
problem
X
by
using
problem
Y
a
black-box
.
If
we
can
2
Identifying
Intractability
of
Problem
through
Reduc
blem
Y,
then
can
solve
problem
X
Therefore,
Y as
is a
also
impossible
toproblem
solve.
a we
black-box
. Ifto
we
can
solve
problem
Y,
Y,as
then
then
we
can
can
solve
solve problem
problem
XX
as
well.
well.
Therefore,
Therefore,
problem
YY isis also
also impossible
impossible
possible
to
solve.
isasalso
impossible
solve.
Xcan
aswe
well.
Therefore,
problem
Ywell.
iswe
also
impossible
,Yproblem
then
solve
problem
X
as
well.
Therefore,
problem
Ytoissolve.
also
to solve.
solve
problem
Y,
then
we
canY
solve
problem
X1 .asIfimpossible
well.
Therefore,
problem Y is also impossible t
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
solve.
an
solve
problem
X
as
well.
Therefore,
problem
is
also
impossible
to
solve.
w
that
we
can
solve
problem
X
by
using
problem
as
a
black-box
we
can
Therefore,
problem
Y
is
also
impossible
to
solve.
We are using NP-hard problems forWe
illustration.
Recall that
NP-hard
problems
have
impossible to solve.
We
are
are using
using
NP-hard
NP-hard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
that
NP-hard
NP-har
We
using
problems
for
illustration.
Recall
that
NP-hard
problems
to
bebe
solved
ininpopt
Weare
arelike
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
toNP-hard
solved
We
are
using
problems
for
Recall
that
proble
Weyet
would
toNP-hard
know
that
problem
thatNP-hard
we
are
attempting
isillustration.
unlikely
to have
have
an
immediate
soluti
We
are
using
NP-hard
problems
foryet
illustration.
Recall
problem
X as
well.
Therefore,
problem
Ythe
is also
impossible
toproblems
solve.
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MIN-VERTEX-COVER
eNP-hard
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
have
yet
to
be
solved
in
polynomial
We
We
are
are
using
using
NP-hard
NP-hard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
that
NP-hard
NP-hard
problems
problems
have
have
yet
yet
to
to be
be
so
so
ms
have
yet
to
be
solved
in
polynomial
or
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
time
time
for
for
more
more
than
than
4
4
decades.
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
a
a
graph
graph
prob
pro
2
Identifying
Intractability
of
a
Problem
through
Reductio
2
Identifying
Intractability
of
a
Problem
through
Redu
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
minimu
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
We
are
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solv
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minim
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
most
common
way
isthat
tobeinvolves
apply
ainfinding
well-known
technique
called
reduction.
Suppose
we
know that
prob
roblems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
roblems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4graph
decades.
MIN-VERTEX-COVER
isth
ll
that
NP-hard
problems
have
yet
to
solved
polynomial
2
Identifying
Intractability
of
a
Problem
throu
2
2
Identifying
Identifying
Intractability
Intractability
of
of
2
a
a
Problem
Identifying
Problem
through
through
Intractability
Reduction
Reduction
of
is
a
graph
problem
a
minimum
subset
of
nodes
such
that
for
every
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
yet
to
be
solved
in
polynomial
time
time
for
for
more
more
than
than
4
4
decades.
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
a
a
graph
problem
problem
that
that
involves
involves
nding
nding
hat
involves
nding
a
minimum
subset
-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
of
of
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
is
is
in
in
ta
tifying
Intractability
a atProblem
through
Reduction
han
4MIN-VERTEX-COVER
decades.
MIN-VERTEX-COVER
isof
aof
graph
that
involves
nding
aby
minimum
1sub
MAX-INDEPENDENTof
nodes
such
that
for
every
edge,
least
one
ofnding
its
endpoint
the
subset.
MAX-INDEPENDENT-S
time
for
more
than
4also
decades.
MIN-VERTEX-COVER
isisat
aXingraph
problem
that
involves
nding
ofRecall
nodes
such
that
for
every
edge,
atproblem
least
one
ofnodes
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT
nodes
such
that
for
every
edge,
least
one
ofsubset
its
endpoint
is in
the
impossible
tolike
solve,
and
we
know
that
we
can
solve
problem
using
problem
Yleast
as immediate
aone
black-box
.aT
I
des.
is
a
graph
problem
that
involves
nding
a
minimum
subset
des.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
a
minimum
subset
of
such
that
for
every
edge,
at
of
its
end
or
illustration.
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
is
a
graph
problem
that
involves
nding
a
minimum
subset
Intractability
of
a
Problem
through
Reduction
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
graph
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
We
would
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
solu
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
es
a graph
minimum
subset
of
of
nodes
nodes
such
such
that
for
for every
every
edge,
edge,
at
at
least
least
one
one
of
of its
its
endpoint
isissubset
in
in the
theat
subset.
subset.
MAX-INDEPE
MAX-INDEPE
set.nding
MAX-INDEPENDENT-SET
isthat
athat
at
least
one
of
its problem
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
afor
graph
graph
problem
problem
of
of
nding
nding
athat
aisendpoint
maximum
maximum
subset
of
of
nodes
nodes
such
such
that
that
for
for eT
hat
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
endp
of
nding
a
maximum
subset
of
nodes
such
that
every
edge,
most
one
of
its
endpo
of
nodes
such
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPEN
graph
problem
of
nding
a
maximum
subset
of
nodes
such
for
every
edge,
at
most
one
of
its
endp
graph
problem
of
nding
a
maximum
subset
of
nodes
such
for
every
e
2
Identifying
Intractability
of
a
Problem
through
Redu
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
We
We
would
would
like
like
to
to
know
know
that
that
the
the
problem
problem
that
that
we
we
are
are
attempting
attempting
We
would
is
is
like
unlikely
unlikely
to
know
to
to
have
have
that
an
an
the
immediate
immediate
problem
that
solution.
solution.
we
are
The
The
att
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
solve.
ry
edge,
at
least
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
isof
athat
ry
at
least
its
endpoint
is
the
subset.
MAX-INDEPENDENT-SET
is
aat
graph
problem
ofsuch
nding
maximum
subset
of
nodes
su
VERTEX-COVER
iscommon
aof
graph
problem
involves
nding
aSuppose
minimum
subset
ndpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
isfor
aof
problem
of
finding
ais
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
toedge,
know
that
theone
problem
that
are
attempting
is
unlikely
tocalled
have
an
immediate
solution.
The
most
common
way
is
to
apply
anodes
well-known
technique
called
reduction.
Suppose
we
know
that
problem
X
most
common
way
is
to
apply
ain
well-known
technique
reduction.
Suppose
we
know
problem
most
way
to
apply
aat
technique
called
reduction.
Suppose
weisthat
know
that
pro
oblem
nding
aone
maximum
subset
such
that
every
edge,
at
one
its
endpoint
in most
X-INDEPENDENT-SET
is
aproblem
graph
graph
problem
of
ofthat
nding
nding
aawell-known
maximum
maximum
subset
subset
of
of
nodes
nodes
such
that
for
for
every
every
edge,
edge,
at
at
most
one
one
dge,
atof
most
one
of
its
endpoint
in
um
subset
nodes
such
that
forwe
every
edge,
most
one
its
endpoint
ismost
in
the
the
subset.
subset.
Suppose
we
we
already
already
know
know
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
isof
isoX
of
nding
aofsubset
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
athat
NP-hard
problem.
we
ci
graph
problem
of
nding
a maximum
subset
of
nodes
such
that
for
every
edge,
atTherefore,
most
one
of
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
ato
NP-hard
problem.
Therefore,
we
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
aX
NP-h
at
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
The
most
common
way
is
to
apply
a
well-known
technique
called
reduction.
Suppose
we
most
most
common
common
way
way
is
is
to
to
apply
apply
a
a
well-known
well-known
technique
technique
most
called
called
common
reduction.
reduction.
way
Suppose
Suppose
is
apply
we
we
know
a
know
well-known
that
that
problem
problem
technique
X
is
1
1
maximum
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
1is
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
the
subset.
Suppose
we
already
know
MIN-VERTEX
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
its
endpoint
is
in
the
subset.
Suppose
we
already
know
that
MIN-VERTEXCOVER
is
way
isimpossible
to
apply
ato
well-known
technique
called
reduction.
Suppose
we
know
that
problem
Xcan
is
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
t.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
Therefore,
we
show
most
one
of
its
endpoint
is
in
the
the
subset.
subset.
Suppose
Suppose
we
we
already
already
know
know
that
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
a
a
NP-hard
NP-hard
problem.
problem.
There
There
hard
problem.
Therefore,
we
can
show
ow
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
Therefore,
we
can
show
that
that
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
is
is
also
also
a
a
NP-hard
NP-hard
problem
problem
by
by
reduc
reduc
We
would
likewe
toalso
know
that
the
problem
that
we
are
attempting
is aproblems
unlikely
to
have
an
immediate
solu
1problem
1reducing
pose
we
already
know
that
MIN-VERTEX-COVER
isknow
asolve
NP-hard
problem.
Therefore,
can
show
1.solved
that
MAX-INDEPENDENT-SET
iswe
also
awe
NP-hard
problem
by
awe
proble
the
subset.
Suppose
already
that
MIN-VERTEX-COVER
is
aas
NP-hard
problem.
Therefo
that
MAX-INDEPENDENT-SET
ismost
also
asolve
NP-hard
problem
by
reducing
MIN-VERTEX-COVER
probl
that
MAX-INDEPENDENT-SET
isreducing
also
apo
apply
a well-known
technique
called
reduction.
Suppose
we
know
that
problem
XNP-hard
isaMIN-VERTEX-COVER
impossible
to
solve,
and
also
know
that
we
can
solve
problem
X
by
using
Y
apM
impossible
impossible
to
solve,
solve,
and
and
we
also
know
know
that
that
we
can
can
problem
problem
impossible
X
X
by
to
by
using
solve,
using
problem
problem
and
Y
as
know
aproblem
aalso
black-box
black-box
that
we
.can
IfIf we
we
solve
can
can
are
using
NP-hard
problems
for
illustration.
Recall
NP-hard
have
yet
to
be
in
1also
eady
know
that
MIN-VERTEX-COVER
NP-hard
problem.
Therefore,
we
can
show
eady
know
MIN-VERTEX-COVER
isiswe
aaproblem
NP-hard
problem.
Therefore,
we
can
show
that
MAX-INDEPENDENT-SET
is
also
a by
NP-hard
m
subset
of
such
that
for
every
edge,
at
one
of
its
endpoint
is
in
ato
NP-hard
problem.
Therefore,
we
can
that
MAX-INDEPENDENT-SET
ainto
EX-COVER
isnodes
a We
NP-hard
problem.
Therefore,
we
can
show
olve,
wethat
also
know
that
we
solve
problem
Xby
by
using
Y
as
aproblem.
black-box
.YYIf
we
can
solve
problem
Y,
then
we
can
solve
problem
Xshow
as
well.
Therefore,
problem
Ywe
isreducing
also
impossible
to
solve.
solve
problem
Y,
then
we
can
solve
X
as
well.
Therefore,
Y
is
also
impossible
to
solve
problem
Y,
then
we
can
solve
problem
X
asaproblem
well.
Therefore,
problem
isis
also
impossible
to proble
solve
X-INDEPENDENT-SET
is
also
acan
NP-hard
reducing
aNP-hard
MIN-VERTEX-COVER
problem
a solve.
lem.
Therefore,
we
can
show
that
that
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
is
is
also
also
a
NP-hard
problem
problem
by
by
reducing
a
a
MIN-VERTEX-COVE
MIN-VERTEX-COV
MIN-VERTEX-COVER
problem
into
a
also
aand
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
problem.
1
most
common
way
is
to
apply
a
well-known
technique
called
reduction.
Suppose
we
know
that
pro
EPENDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
MAX-INDEPENDENT-SET
problem.
that
MAX-INDEPENDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
MAX-INDEPENDENT-SET
problem.
MAX-INDEPENDENT-SET
problem.
e
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
imp
solve
solve
problem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
X
as
as
well.
well.
Therefore,
Therefore,
solve
problem
problem
problem
Y,
then
Y
Y
is
is
we
also
also
can
impossible
impossible
solve
problem
to
to
solve.
solve.
X
as
well.
T
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
T-SET
also
NP-hard
problem
byNP-hard
reducing
a MIN-VERTEX-COVER
MIN-VERTEX-COVER
problem
into
problem
reducing
a aMIN-VERTEX-COVER
problem
aaaMAX-INDET-SET
also
aaNP-hard
NP-hard
problem
reducing
problem
into
problem.
w
that
MIN-VERTEX-COVER
aby
problem.
Therefore,
show into
blem
byisis
reducing
a problem.
MIN-VERTEX-COVER
problem
into
a MAX-INDEPENDENT-SET
Y,
then
we
can
solve
problem
Xisby
as
well.
Therefore,
problem
Y iswe
alsocan
impossible
to solve.
DEPENDENT-SET
TEX-COVER
problem
into
asolve,
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
problem.
problem.
m.
impossible
tothat
and
weproblem
also know
weimpossible
canitssolve
problem
X the
by using
problem
Y as a black-box1 .
NDENT-SET
problem.
ability
of
a
Problem
through
Reduction
problem.
can
solve
problem
XMAX-INDEPENDENT-SET
as
well.
Therefore,
Yleast
isthat
also
to
solve.
of
nodes
such
for
every
edge,
at
one
of
endpoint
is
in
subset.
MAX-INDEPENDENTPENDENT-SET
problem.
T
problem.
T
problem.
also
a NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
Wesolve
areWe
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in polynom
polynom
We
are
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
are
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to be solved
in p
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
problem
Y,
then
we
can
solve
problem
Xthat
asfor
well.
Therefore,
problem
Y
isatbe
also
impossible
solve
We
will
rst
prove
following
lemmas.
We
will
rst
prove
the
following
two
lemmas.
Wetwo
will
rst
prove
the
following
two
lemmas.
Wethe
are
using
NP-hard
problems
illustration.
Recall
that
NP-hard
problems
have
yet
We
We
are
are
using
using
NP-hard
NP-hard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
NP-hard
NP-hard
are
using
problems
problems
NP-hard
have
have
problems
yet
yet
to
to
be
for
solved
solved
illustration.
in
in
polynomial
polynomial
Recall
t
graph
problem
of
nding
aMIN-VERTEX-COVER
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
itsto
endpo
We
will
first
prove
the
following
two
lemmas.
We
will
rst
prove
the
following
two
lemmas.
2
Identifying
Intractability
of
a
Problem
through
m.
2
Identifying
Intractability
of
a
Problem
through
Red
gill
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
sub
time
for
more
than
4
decades.
is
a
graph
problem
that
involves
nding
a
minimum
sub
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimu
rst
prove
the
following
two
lemmas.
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
two
lemmas.
that we
are
attempting
is unlikely
to
havethe
anfollowing
immediate
solution.
The Intractability of a Pro
prove
the
following
two
lemmas.
2
Identifying
We
will
rst
prove
two
lemmas.
roblems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves

time
time
for
more
more
than
than
4
4
decades.
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
time
a
a
graph
graph
for
problem
more
problem
than
that
that
4
decades.
involves
involves
nding
MIN-VERTEX-COVER
nding
a
a
minimum
minimum
subset
subset
is
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
Therefore,
we
c
for
Lemma
Lemma
1.
1.
If
If
S
S

V
V
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E)
E)
2
Identifying
Intractability
of
a
Problem
through
Reduction
following
two
lemmas.
Problem
through
Reduction
following
lemmas.
than
4technique
decades.
MIN-VERTEX-COVER
isLemma
a we
graph
problem
that
involves
nding
a,the
minimum
subset
of two
nodes
such
that
for
every
edge,
at
least
one
ofSone
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
of
nodes
such
that
edge,
at
least
one
of
its
endpoint
is
the
subset.
MAX-INDEPENDENT-SET
of
nodes
such
that
every
edge,
at
least
of of
its
endpoint
isE),
in
subset.
MAX-INDEPENDENT
Lemma
1.
Ifusing
S
Vfor
anan
INDEPENDENT-SET
graph
G(V,
then
VV
Shave
Lemma
1.
If
is
is
an
INDEPENDENT-SET
then
is
isisaayet
Lemma
1.
Iffor
Severy

VisSuppose
INDEPENDENT-SET
ofgraph
graph
G(V,
E),
then
S
aVERTEX-COVE
VERTEX-COV
1.
Ifthat
problem
V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),ofthen
nown
called
reduction.
know
X
isIfin
We
are
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
to
be
inaas
Lemma
1.
S

V
is
an
INDEPENDENT-SET
gra
We
would
like
to
know
that
the
problem
that
we
are
attempting
is is
unlikely
to
have
imme
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
des.
is
a
graph
problem
involves
nding
a
minimum
subset
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
in
the
subset.
MAX-IN
of
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
of
nodes
is
is
in
such
in
the
the
that
subset.
subset.
for
every
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
edge,
at
least
one
of
its
isisend
that
MAX-INDEPENDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
proble
1.
IfVMIN-VERTEX-COVER
Snodes

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
the
Lemma
Lemma
1.
1.
If
If
S
S

V
V
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V

S
Sits
is
isendpoint
asolved
aan
VERTE
VERTE
Vof

S
is
a
VERTEX-COVER
of
the
ENDENT-SET
of
graph
G(V,
E),
then

S
is
a
VERTEX-COVER
of
the
graph
graph
G(V,
G(V,
E)
E)
two
lemmas.
1
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
the
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
iui
VERTEX-COVER
of
the
graph
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endp
graph
G(V,
E)
Lemma
1.
If
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX
G(V,
E)
graph
G(V,
E)
ability
of
a
Problem
through
Reduction
.
at
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
nsing
of
graph
G(V,
E),
then
Vare

Sthe
issuch
VERTEX-COVER
of
the
time
fornding
more
than
4E)
decades.
MIN-VERTEX-COVER
is
aevery
graph
problem
that
involves
nding
aat
minim
ngraph
INDEPENDENT-SET
of
G(V,
E),
then

S
is
aagraph
VERTEX-COVER
of
the
G(V,
E)
G(V,
E),
then
V

Sgraph
away
VERTEX-COVER
ofaMAX-INDEPENDENT-SET
We
like
to
know
that
problem
that
we
attempting
is
unlikely
to
have
immediate
solution.
The
iswould
unlikely
to
have
an
immediate
The
most
common
way
is
to
apply
amaximum
well-known
technique
called
reduction.
Suppose
we
most
common
issolution.
to
apply
aV
well-known
technique
called
Suppose
we
know
that
ry
edge,
at
one
of
its
endpoint
in
the
subset.
is
amost
graph
problem
of
nding
subset
of
such
that
for
every
edge,
most
graph
graph
problem
problem
of
of
nding
ais
athe
maximum
maximum
subset
subset
of
of
nodes
nodes
such
graph
that
that
problem
for
for
every
ofaanodes
edge,
nding
edge,
at
atendpoint
aan
most
maximum
one
one
ofsubset
its
its
endpoint
endpoint
of
nodes
isknow
is in
su
in
MAX-INDEPENDENT-SET
problem.
V,
E)
aINDEPENDENT-SET
VERTEX-COVER
of
the
graph
graph
G(V,
G(V,
E)
of
nding
aleast
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
ofaisreduction.
its
is of
in
thewell.
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
NP-hard
problem.
Therefore,
we
can
sh
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
is
NP-hard
problem.
Therefore,
we
can
sh
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
a
NP-hard
problem.
Therefore,
we
graph
G(V,
E)
ing
Intractability
of
a
Problem
through
Reduction
em
X
as
Therefore,
problem
Y
is
also
impossible
to
solve.
most
common
way
is
to
apply
well-known
technique
called
reduc
Proof.
Proof.
Let
us
us
assume
assume
that
that
VSuppose
Vis

in
SSXthe
is
is
not
not
aaby
VERTEX-COVER.
VERTEX-COVER.
Ther
Ther
of
nodes
such
that
for
every
edge,
at
least
one
of
itsthat
endpoint
subset.
MAX-INDEPENDENT
of
graph
G(V,
E),
then
Vthat

SMIN-VERTEX-COVER
is
anot
VERTEX-COVER
of
the
Proof.
Let
us
assume
that
is
aaat
VERTEX-COVER.
Therefore,
there
are
two
common
way
is
to
apply
athat
well-known
called
reduction.
we
know
that
problem
XA,
is
dmost
reduction.
Suppose
we
know
problem
Xis
isnot
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
using
problem
Y
as
aBb
impossible
to
solve,
and
we
also
know
that
we
can
solve
using
problem
Y
as
acan
black-bo
aENDENT-SET
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
endpoint
is
in
the
subset.
we
already
know
MIN-VERTEX-COVER
is
atwo
NP-hard
problem.
the
thewe
subset.
subset.
Suppose
Suppose
we
we
already
already
know
know
that
MIN-VERTEX-COVER
the
subset.
is
Suppose
a
aproblem
NP-hard
NP-hard
we
problem.
problem.
already
know
Therefore,
that
MIN-VERTEX
we
we
can
show
show
Proof.
Let
us
that
VSuppose

S
VERTEX-COVER.
Therefore,
there
are
B
/
Proof.
Let
us
assume
that
V

Stechnique
is
not
aLet
VERTEX-COVER.
there
are
two
vertices
A,
Let
us
assume
that
Visits
STherefore,
isTherefore,
not
aby
VERTEX-COVER.
Therefore,
that
are
attempting
isassume
unlikely
to
have
an
solution.
The
ppose
we
already
know
that
MIN-VERTEX-COVER
is
NP-hard
problem.
can
show
that
MAX-INDEPENDENT-SET
isProof.
also
aand
NP-hard
problem
by
reducing
MIN-VERTEX-COVER
problem
int
Proof.
Let
us
assume
that
VMIN-VERTEX-COVER

STherefore,
is
not
a1vertices
VERTEX-CO
that
MAX-INDEPENDENT-SET
is
also
NP-hard
problem
by
reducing
aaknow
MIN-VERTEX-COVER
problem
int
that
MAX-INDEPENDENT-SET
isaimmediate
also
aSaS
NP-hard
problem
by
reducing
awe
probl
impossible
to
solve,
and
we
also
that
we
can
solve
problem
Xend
by
1
et
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/
V

S
Proof.
Proof.
Let
Let
us
us
assume
assume
that
that
V
V

is
is
not
not
a
a
VERTEX-COVER.
VERTEX-COVER.
Therefore,
Therefore,
there
there
are
are
two
two
vertic
vertic
there
are
two
vertices
A,
B

/
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/
V

S
and
there
there
is
is
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
A,
B
B

/
V
V

S,
S,
we
we
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
vertices

and
there
is
an
edge
connecting

and
.
Since
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
m
X
by
using
problem
Y
as
a
black-box
.
If
we
can
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossib
ssume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/
V

S
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
so
ready
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
Therefore,
we
can
show
that
MAX-INDEPENDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX
that
that
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
is
is
also
also
a
a
NP-hard
NP-hard
problem
problem
that
by
by
MAX-INDEPENDENT-SET
reducing
reducing
a
a
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
also
a
problem
problem
NP-hard
into
into
proble
a
a
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
are
co
We
will
rst
prove
the
following
two
lemmas.
Proof.
Let
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertice
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
are
c
and
is
an
edge
connecting
A
and
B.
A,A
Band

/a VB.Since
S, weA,
have
ow
that
the
problem
that
we
are
attempting
isB
unlikely
to
have
an
immediate
solution.
The
nown
technique
called
reduction.
Suppose
wethere
know
that
problem
XBis
isA,
DEPENDENT-SET
is
also
athere
NP-hard
problem
by
reducing
atwo
MIN-VERTEX-COVER
problem
into

is
not
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B
/is

SSince
VV

SSMAX-INDEPENDENT-SET
is
not
aathat
VERTEX-COVER.
Therefore,
there
are
A,
B
//
VVA

S
MAX-INDEPENDENT-SET
problem.
and
there
anS.
edge
connecting
B

/A
problem.
Therefore,
there
are
two
vertices
A,

/be
V

S
MAX-INDEPENDENT-SET
problem.
stration.
Recall
NP-hard
problems
have
yet
solved
in
polynomial
solve
problem
Y,vertices
then
we
can
solve
problem
X
as
well.
Therefore,
pro
etCOVER.
isBMAX-INDEPENDENT-SET
an
edge
connecting
A
and
B.
Since
A,
B

/to

S,
we
have
A,

As
B
are
connected
two
vertices
A,
B
/and
Vimpossible

S
and
there
isproblem.
isto
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
B
B

Vby
V

S,
S,
we
we
have
have
A,
A,
B
B Therefore
S.
S. As
As A
AThis
and
and
A,
B.
S.
As
A
and
B
are
connected
and
Since
A,
B

/and
Vwe

S,
we
have
A,
B

S.
As
A
B
are
connected
by
by
an
an
edge,
edge,
we
we
note
note
that
that
S
S
not
not
an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
Thi
,note
we
have
.V
As
and
and
Since
are
connected
an
edge,
we
note
the
subset.
Suppose
we
already
that
MIN-VERTEX-COVER
isinto
aand
NP-hard
problem.
Therefore,
we
solve
problem
Y,
then
can
solve
problem
Xknow
as
well.
Therefore,
problem
Y
isis
also
impossible
to
solve.
ore,
problem
Y
isNP-hard
also
solve.
edge
connecting
A
B.
Since
A,
B

/
V

S,
we
have
A,

S.
As
A
and
B
are
connected
T-SET
is
also
a
problem
by
reducing
a
MIN-VERTEX-COVER
problem
a
MAX-INDEPENDENT-SET
problem.
MAX-INDEPENDENT-SET
problem.
MAX-INDEPENDENT-SET
problem.
1 B that
by
an
edge,
we
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
V

there
is
an
edge
connecting
A
and
B.
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V
by
an
edge,
we
note
S
is
not
an
INDEPENDENT-SET.
This
is
a
c
is
to
apply
a
well-known
technique
called
reduction.
Suppose
we
know
that
problem
X
is
at
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
NDENT-SET
problem.
ecting
Aand
and
B.
Since
A,
B
/This
VVINDEPENDENT-SET.

S,
we
have
A,
B

S.
As
A
and
BVSare
are
connected
tifying
Intractability
of
aare
Problem
Reduction
ecting
and
B.
A,

/
V

we
A,
B
S.
As
A
and
B
byaisINDEPENDENT-SET.
an
edge,
we
note
that
SVMIN-VERTEX-COVER
isisisnot
an
INDEPENDENT
stge,
not
aA
VERTEX-COVER.
Therefore,
there
two
vertices
A,
B

/
is
Sconnected

/As
Vwe
S,
we
have
VB
S.
As
A
and
Bhave
are
connected
TEX-COVER
is
aSince
graph
problem
that
nding
aanot
minimum
subset
Lemma
If
SWe

is
INDEPENDENT-SET
of
graph
G(V,
E),
then
is
aa VERTEX-COVE
note
that
SA,
is
not
an
This
athrough
contradiction.
Therefore
VSis
S
isyethave
a to be
A
B
are
connected
by
byB
an
an
edge,
edge,
we
we
note
note
that
that
S
S
isis
not
an
an
INDEPENDENT-SET.
This
This
aa
contradiction.
contradiction.
Ther
The
that
1.
is
not
an
INDEPENDENT-SET.
This
is
contradiction.
Therefore
is
contradiction.
Therefore

S
is
aan
an
INDEPENDENT-SET.
isS,
ainvolves
contradiction.
Therefore
V
areducing
VERTEX-COVER.
VERTEX-COVER.
that
MAX-INDEPENDENT-SET
is
also
NP-hard
problem
by
aproblems
prob
are
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
yet
to
be
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
a
We
are
using
NP-hard
problems
for
illustration.
Recall
that
NP-hard
have
solved
T
problem.
1 This
VERTEX-COVER.
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
is
a
contradiction.
There
VERTEX-COVER.
VERTEX-COVER.
we
also
know
can
solve
problem
using
problem
Y connected
asisaablack-box
.is
we can
em
X
as
well.
Therefore,
problem
Ythe
isThis
also
impossible
is
not
an
INDEPENDENT-SET.
This
is
contradiction.
Therefore
SS for
isIfaaillustration.
SS one
is
an
INDEPENDENT-SET.
is
contradiction.
Therefore
VV
We
will
rst
prove
the
following
two
lemmas.
VERTEX-COVER.
and
B.not
Since
A,
Bathat

/contradiction.
VSiswe

S,
we
have
A,
Bproblem.
XaaS.
As
and
B are
We
will
rst
prove
the
following
two
lemmas.
NT-SET.
This
isWe
Therefore
Vby

SA
isto
asolve.
will
rst
prove
following
two
lemmas.
st
of
its
endpoint
in
subset.
MAX-INDEPENDENT-SET
We
are
using
NP-hard
problems
Recall
that NP-hard
VERTEX-COVER.
graph
G(V,
E)
-COVER.
tion.
Therefore
V

is
athe
VERTEX-COVER.
VERTEX-COVER.
MAX-INDEPENDENT-SET
Wecan
are
using
NP-hard
problems
illustration.
Recall
that
NP-hard
problems
have
yet
to
be solved
in involves
polynomial
NP-hard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4lemmas.
decades.
MIN-VERTEX-COVER
issolve.
a problem
graph
problem
that
ndin
ER.
time
for
more
than
4are
decades.
MIN-VERTEX-COVER
is
aimmediate
graph
that
involves
nding
min
We
will
rst
prove
the
following
two
lemmas.
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
We
will
rst
prove
the
following
two
lemmas.
VERTEX-COVER.
to
know
that
the
problem
that
weisfor
attempting
is unlikely
to
have
an
solution.
en
we
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
Lemma
Lemma
2.
2.
If
If
S
S

V
V
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
ofThe
graph
graph
G(V,
G(V,
E),
E),a prob
then
the
t
prove
the
following
two
lemmas.
an
INDEPENDENT-SET.
This
a
contradiction.
Therefore
V

S
is
a
bset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a graph
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT-SE
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT-S
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V of

time
for
more
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
ph
problem
that
involves
nding
a
minimum
subset
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEP
Lemma
1.
If
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDE
following
two
lemmas.
Lemma
1.
If
S

V
is
an
INDEPENDENT-SET
of
G(V,
E),
then
V

S
is
a
VERTEX-COVER
Lemma
2.
If

is
a
VERTEX-COVER
graph
,
then

an
INLemma
1.
If
S

V
is
an
INDEPENDENT-SET
graph
G(V,
E),
then
V

S
is
a
VERTEX-COV
nX-COVER
way
to
apply
aLet
well-known
technique
called
reduction.
Suppose
we
know
that
problem
X SS
isofisisthe
Proof.
usE),
assume
that
VS
is
not
aG(V,
VERTEX-COVER.
Therefore,
there
two
vertices
A,
B
2.
IfVan
Sis

V
is
a SS
VERTEX-COVER
graph
E),
then
Vthat

Sof
is
an
INDEPENDENT-SET
Lemma
Lemma
2.
2.
IfIfthe
SSof

VV
is
isS
aaG(V,
VERTEX-COVER
VERTEX-COVER
of
graph
graph
G(V,
G(V,
E),
E),
then
then
VVare

an
anVINDEPEND
INDEPEND
stration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
S
isLemma
INDEPENDENT-SET
of
of
graph
G(V,
then
V

is
an
INDEPENDENT-SET
of
the
graph
graph
G(V,
E)
E)
at
MIN-VERTEX-COVER
a
NP-hard
problem.
Therefore,
we
can
show
of
nodes
such
for
every
edge,
at
least
one
of
its
endpoint
is
in
t

is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT-SET
of
the
Lemma
1.
If
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then

S
is
a
Lemma
1.
1.
Lemma
1.
If
If

V
V
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E),
E),
If
then
then
S

V
V

is
S
S
an
is
is
INDEPENDENT-SET
a
a
VERTEX-COVER
VERTEX-COVER
of
of
of
the
the
gra
graph
G(V,
E)
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDE
graph
G(V,
E)
V
graph
G(V,
E)
We
will
rst
prove
the
following
two
lemmas.
1
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
t-hard
is
in
the
subset.
MAX-INDEPENDENT-SET
is
a
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
the
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT-SET
of
the
VERTEX-COVER
of
graph
G(V,
E),
then
Vmaximum

Sproblems
isB.
an
INDEPENDENT-SET
ofhave
the
graph
G(V,
E)
DEPENDENT-SET
of
the
graph
graph
G(V,
E)
graph
problem
of
nding
aproblem
of
nodes
for
every
at
most
oneBofare
itscoeV
graph
G(V,
E)
G(V,
E),
then
Vathere

S
isthat
anG(V,
INDEPENDENT-SET
ofby
the
graph
G(V,
E)
.subset
solve,
and
we
also
know
we
can
solve
X
using
problem
Ysuch
as
athat
black-box
.B
Ifedge,
weS.can
and
is
an
edge
connecting
A
and
Since
A,
B

/
V

S,
we
A,

As
A
and
V,
E)
problems
for
illustration.
Recall
that
NP-hard
have
yet
to
be
solved
in
polynomial
NDEPENDENT-SET
of
the
graph
graph
G(V,
E)
E)
TEX-COVER
is
graph
problem
that
involves
nding
a
minimum
subset
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
graph
of is
nding
maximum
subset
nodes
such
that
for
e
ngraph
INDEPENDENT-SET
ofaG(V,
graph
G(V,
E),
then
V problem
SThe
is proof
agraph
VERTEX-COVER
of
the
graph
E)
graph
graph
G(V,
G(V,
E)
E)
G(V,
E)athe
graph
E)its
problem
of
nding
maximum
subset
ofis
nodes
such
that
for
every
edge,
atto
one
endpoint
is
for
every
edge,
at
most
one
endpoint
in
Proof.
Proof.
The
proof
is
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
Let
us
usinassu
assu
the
subset.
we
already
know
that
MIN-VERTEX-COVER
is
aof
NP-hard
problem.
The
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
ismost
athat
NP-hard
problem.
Therefore,
X-COVER
ofMIN-VERTEX-COVER
graph
G(V,
E),
then
VSuppose
S
is
an
INDEPENDENT-SET
Y,decades.
then
can
solve
problem
X
as
well.
Therefore,
problem
Y
isof
also
impossible
solve.
Proof.
The
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
Sof
not
aVERTEX-COV
INDEPENDE
by
an
edge,
we
note
S
is
not
an
INDEPENDENT-SET.
This
is
athat
contradiction.
Therefore
V

4at
is
graph
problem
that
involves
nding
aus
minimum
subset
Proof.
The
proof
isof
actually
similar
to
the
previous
lemma.
Let
assume
Sisits
is
not
avertices
INDEPEND
st
one
ofwe
its
endpoint
is
in
subset.
MAX-INDEPENDENT-SET
issimilar
aof
Proof.
The
proof
isSuppose
actually
to
the
previous
lemma.
Let
us
assume
tha
Lemma
1.proof
If the
S

Vthat
isa
an
INDEPENDENT-SET
graph
G(V,
E),
then
VV

is
aprevious
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
is
the
subset.
we
already
know
that
MIN-VERTEX-COVER
is
Proof.
Let
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/
V

Proof.
The
proof
is
actually
similar
to
the
lemma.
Proof.
Let
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/
V

Proof.
Let
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
A,
B
proof
actually
similar
to
the
previous
lemma.
Let
usa assume
that
V

S
isproblem
not
aA,
INDEPENDENT-SET.
Proof.
Proof.
The
The
proof
proof
is
isus
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
Let
us
us
assume
assume
that
V
V

SSthere
isisis
not
not
aa
IND
IND
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
isTherefore,
alemma.
NP-hard
problem.
we
can
show
VER
isSprevious
aisis
NP-hard
problem.
Therefore,
we
can
show
the
Visthe

not
aus
INDEPENDENT-SET.
to
lemma.
Let
us
assume
that
VLet
aA,
SA,
isassume
INDEPENDENT-SET.
Therefore,
Therefore,
there
there
are
two
two
vertices
vertices
A,
B
B
reducing
Vtwo
VaVisTherefore,

Sthat
SA
and
there
there
is
an
an
edge
edge
that
MAX-INDEPENDENT-SET
also
aare
NP-hard
by
aand
MIN-VERTEX-CO
that
MAX-INDEPENDENT-SET
isnot
also
aisthe
NP-hard
problem
by
reducing
MIN-VERTEX-COVER
pr
of
actually
similar
to
the
previous
lemma.
us
that
V

S
is
not
a
INDEPENDENT-SET.
Proof.
Let
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
are
two
Proof.
Proof.
Proof.
Let
Let
us
assume
assume
that
that
V
V

S
S
is
is
not
not
a
VERTEX-COVER.
VERTEX-COVER.
Therefore,
Let
us
assume
there
there
that
are
are
two

S
vertices
vertices
is
not
A,
A,
a
VERTEX-CO
B
B

/
V
V

S
S
Therefore,
there
are
two
vertices
B

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
VERTEX-COVER.
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
a
Proof.
The
proof
is
actually
similar
to
previous
Let
us
assume
that
V

S
is
not
a
INDE
Therefore,
there
are
two
vertices
B

S
and
there
is
an
edge
connecting
and
B.
Since
A,
B
bset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
Therefore,
there
are
vertices
A,
B

S
and
there
is
an
edge
conne
not
a
INDEPENDENT-SET.
Therefore,
there
two
vertices

and
graph
G(V,
E)
that
Vprevious

San
is
not
aconnecting
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
B

/NP-hard
VB
ysassume
similar
to
the
previous
lemma.
Let
us
assume
that
B.
SA,
is
not
aA,
INDEPENDENT-SET.
that
MAX-INDEPENDENT-SET
isA,
also
aS.
problem
by
reduc
yye,
similar
to
lemma.
Let
assume
that
VV

S
is
not
INDEPENDENT-SET.
and
there
is
an
edge
connecting
Aatwo
and
B.
Since
A,
B
V

S,
we
have
A,
B
A,
S.
As
ASVan
and
Band
are
connec
Therefore,
there
are
two
vertices
A,
B

Vedge,

S
and
ther
and
there
is
A
and
B.
Since
A,
B

/a/V
V
we
have
B

As
A
and
B
are
connec
ma.
Let
us
assume
that
Vedge

SB
is
not
aus
INDEPENDENT-SET.
and
there
is
an
edge
A
and
Since
B

/S,
V

S,
we
have
B

S.
As
A
B
are
c
there
are
two
vertices
A,

Vthere

STherefore,
and
there
an
edge
connecting
A
and
B.
Since
A,

S,
not
aMAX-INDEPENDENT-SET
INDEPENDENT-SET.
Therefore,
Therefore,
there
are
are
two
vertices
vertices
A,
B
B
V

S
S
and
and
there
there
is
is
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Sin
Sin
isconnecting
also
NP-hard
problem
by
reducing
aand
MIN-VERTEX-COVER
problem
into
aB
reducing
athe
MIN-VERTEX-COVER
problem
into
ais
A
and
B.
Since
A,

Vthere

S,
,that
B

VS

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

S,
we
we
have
have
A,
A,
B
B

/
/
S.
S.
As
As
A
AA,
and
B
B
are
are
connected
connected
by
by
an
edge,
we
we
note
note
MAX-INDEPENDENT-SET
problem.
MAX-INDEPENDENT-SET
problem.
ng
NP-hard
problems
for
illustration.
Recall
that
NP-hard
problems
have
yet
to
be
solved
in
polynomial
eat
are
vertices
A,
B

VB

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

V
we
S,
tcting
VMIN-VERTEX-COVER
two
is
not
aan
VERTEX-COVER.
there
are
two
vertices
B

/A,
V

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/S,
V

S,
have
A,
B

S.
As
and
and
there
there
is
is
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
A,
B
B

/
and
V

there
S,
S,
we
we
is
have
an
have
edge
A,
B
B
connecting

S.
S.
As
As
A
A
A
and
and
and
B
B
B.
are
are
Since
connected
connected
A,

/
we
have
A,
B

/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
T
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
Therefore,
are
two
vertices
S
there
is
an
edge
connecting
A
and
B.
Sinc
we
have
A,
B

/
S.
As
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
is
edge
connecting

and
.
Since
,
have
.
As

and
is
a
NP-hard
problem.
Therefore,
we
can
show
we
have
A,
B

/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
n
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
are
connected
ertices
A,
B

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

S,
emmas.
MAX-INDEPENDENT-SET
problem.
ertices
A,
B

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
we
have
A,
B

/
S.
As
A
and
B
are
connected
by
an
edg
o
the
previous
lemma.
Let
us
assume
that
V

S
is
not
a
INDEPENDENT-SET.
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
here
is
an
edge
connecting
Aconnected
and
B.
A,
B

Vnot

S,of
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
isnote
aINDEPENDENT-SET.
Therefore
VBi
Lemma
2.
If
S

Vby
isedge,
aSince
VERTEX-COVER
graph
G(V,
E),
then
V

Scontradiction.
is
an
INDEPENDENT-SE
B

/
S.
As
A
and
B
are
by
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
This
is
a
and
B.
Since
A,
B

S,
we
we
have
have
A,
A,
B
B

/
S.
S.
As
As
A
A
and
and
B
B
are
are
connected
connected
by
by
an
an
edge,
edge,
we
we
note
that
that
S
S
is
is
not
not
a
a
VERTEX-C
VERTEXMAX-INDEPENDENT-SET
problem.
is
not
a
VERTEX-COVER.
This
is
a
eA,
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
This
is
a
contradiction.
contradiction.
Therefore
Therefore
V
V

S
S
is
is
an
an
INDEPENDENT-SET.
Proof.
Let
us
assume
that
V

S
is
a
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
than
4
decades.
MIN-VERTEX-COVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
S.
As
A
and
B
are
connected
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
This
is
a
ecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
are
connected
by
an
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction
by
by
an
an
edge,
edge,
we
we
note
note
that
that
by
edge,
note
that
SS
is
not
an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
This
This
isisedge,
aan
aTherefore
contradiction.
contradiction.
Sshow
isisis
not
Therefore
INDEPENDENT
V
SS isis aa
is
are
connected
by
an
edge,
we
note
that
problem
iscontradiction.
notanaBVERTEX-COVER.
aTherefore
concontradiction.
Therefore
V
Sthat
isand
an
INDEPENDENT-SET.
we
already
know
that
MIN-VERTEX-COVER
isSSan
ais
NP-hard
problem.
we
can
we
have
A,VERTEX-COVER.
B

/not
S.
As
A
areisisaTherefore
connected
by
an
we
that
S
isan
not
a VVERTEX-C
contradiction.
V

S
is
INDEPENDENT-SET.
and
NP-hard
problem
aiswe
MIN-VERTEX-COVER
into
aSwe
contradiction.
V
Therefore,
INDEPENDENT-SET.
eVERTEX-COVER.
note
that
S
not
an
INDEPENDENT-SET.
This
aVERTEX-COVER.
contradiction.
V

S
is
aINDEPENDENT-SE
and
B
are
connected
by
an
we
note
that
isB
not
aan
This
isnote
B
are
connected
by
an
edge,
note
not
VERTEX-COVER.
This
is
VERTEX-COVER.
Therefore
VaaThis

S
an
B

V
note
S
and
is
an
edge
connecting
A
and
B.
Since
S,
VERTEX-COVER.
edge,
we
that
Sby
isreducing
not
aTherefore
This
alemmas.
VERTEX-COVER.
graph
G(V,
E)
tion.
Therefore
Visthere

S
is
an
INDEPENDENT-SET.
This
is
aedge,
contradiction.
contradiction.
Therefore
Therefore
V
VA

SS
isis
an
INDEPENDENT-SET.
INDEPENDENT-SET.
an
INDEPENDENT-SET.
We
will
rst
prove
the
following
twoA,A,
lemmas.
and
there
is
an
edge
connecting
and
B.
Since
Bthe

/VV
S,
we
have
A,
B

We
will
rst
prove
the
following
two
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAX-INDEPENDENT-SET
isS.a As A and B are
ENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
Therefore
V

S
an
INDEPENDENT-SET.
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
is
a
tradiction.
Therefore

is
an
INDEPENDENT-SET.
VERTEX-COVER.
VERTEX-COVER.
VERTEX-COVER.
VERTEX-COVER.
NDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
contradiction.
Therefore
V

S
is
an
INDEPENDENT-SET.
Theorem
1.
1.
IfIf SS

ofVThis
V
isis
aaisfollowing
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
of
graph
graph G(V
G(V
ER.
SSWe
an INDEPENDENT-SET.
INDEPENDENT-SET.
We
rst
prove
the
two
lemmas.

isis an
connected
by
edge,
we
note
is
aTheorem
VERTEX-COVER.
a G(V,
-SET.
Theorem
1.
IfVVfollowing
S
note
Vthat
isthat
graph
E),
then
VV
Sof
isgraph
Theorem
1.
If
S

Vnodes
isaaSaMAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
graph
then
S
isa aMIN-VERTEX
MIN-VERTE
will
rst
prove
the
two
lemmas.
Theorem
1.of
Ifwill
S of

V
is at
aE),
MAX-INDEPENDENT-SET
G(V, E),of
t
byan
an
edge,
we
Snot
is that
not
an
INDEPENDENT-SET.
This
isis
aMAX-INDEPENDENT-SET
contradiction.
Therefore
m
of nding
aV
maximum
subset
of
such
for
every
edge,
most
one
of
its
endpoint
is
in
Lemma
2.
S2.

is
a1.
VERTEX-COVER
of
graph
G(V,
E),
then
V
MIN-VERTEX-COVER
S
an
INDEPENDENT-SET
ofoV
Theorem
1.
Ifus
SG(V,

V
isE),
ais
Lemma
2.
IfIf
S

is
a1.
VERTEX-COVER
graph
G(V,
then
V

S
an
INDEPENDENT-SET
Lemma
If
SIf
S
V
is
VERTEX-COVER
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT-SE
NT-SET
problem.
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
assume
that
V

S
is
not
a
INDEPENDE
m
If
S

is
a
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
Theorem
Theorem
If
If
S
S

V
V
is
is
a
a
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V

S
S
is
is
a
MINMIN
hen
V

S
is
a
MIN-VERTEX-COVER
NDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
MIN-VERTEX-COVER
of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
Lemma
1.
If
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERT
Theorem
1.

is
a
MAX-INDEPENDENT-SET
of
graph
,
then
Lemma
1.
If
V
is
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-C
nS 1.
INDEPENDENT-SET.

V
is
a
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
MIN-VERTEX-COVER
Lemma
2.
If
S

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

an
INDE
Lemma
Lemma
2.
2.
Lemma
2.
If
If
S
S

V
V
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
If
V
V
S

S
S
V
is
is
is
an
an
a
VERTEX-COVER
INDEPENDENT-SET
INDEPENDENT-SET
of
graph
of
of
the
the
G
of
the
graph
G(V,
E).
Theorem
1.
If
S

V
is
a
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
S
is
a
MIN-V
of
the
graph
G(V,
E).
of
the
graph
G(V,
E).
VERTEX-COVER.
uppose
we
that
MIN-VERTEX-COVER
isVgraph
a
NP-hard
problem.
Therefore,
canofAshow
SLemma
graph
VMIN-VERTEX-COVER
isthen
aalready
VERTEX-COVER
of
graph
G(V,
E),
then
V1.
S
is
the
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
MIN-VERTEX-COVER
Lemma
Ifand
an
V .INDEPENDENT-SET
isis
an
graph
E)
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
VV

SSSof
isis
aaS
MIN-VERTEX-COVER
graph
G(V,
E)
the
graph
G(V,
E).
graph
G(V,
E)
of
G(V,
E),
then
VE)
graph
SG(V,
is
aG(V,
MIN-VERTEX-COVER
G(V,
lemmas.
Therefore,
there
are
two
vertices
A,
Bvertices
of

anINDEPENDENT-SET
edge
andofB.
Since
A, B
E).
S
aG(V,
of
the
graph
G(V,
E).
E).
1.
Ifgraph
S
know
V of
is
an
INDEPENDENT-SET
G(V,
E),
then
V
of
Sconnecting
is aweVERTEX-COVER
ofG(V,
the
G(V,
E),
VE)

S
is
athe
VERTEX-COVER
of
the
graph
E)
isgraph
MIN-VERTEXCOVER
of
the
graph
graph
G(V,
E)
taph
aisE).
VERTEX-COVER.
Therefore,
there
are Vtwo
A,
B

/ there
Vthat
V
SV
V,
VERTEX-COVER
of
G(V,
E),
then
Proof.
S
is
an
INDEPENDENT-SET
the
graph
G(V,
E)
graph
graph
G(V,
G(V,
E)
graph
G(V,
E)
of
the
graph
G(V,
E).
Proof.
We
We
know
know
that

S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
on
o
DEPENDENT-SET
is
also
a
NP-hard
problem
by
reducing
a
MIN-VERTEX-COVER
problem
into
a
graph
G(V,
E)
DEPENDENT-SET
oflemmas.
graph
G(V,
E),
then

S
is aknow
MIN-VERTEX-COVER
ve
the following
twoWe
byby
Proof.
know
that
V

SVERTEX-COVER
is
athe
cover
lemma
1.
only
thing
for
us
pro
we
have
A,
Bis

/actually
S.
As
AV
and
BVisthe
are
connected
by
an
edge,
we
note
that
S
is
not
aremains
VERTEX-COVER.
Proof.
We
know
that
S
avertex
vertex
cover
1.aThe
The
only
thing
that
remains
forby
usto
tothin
p
graph
G(V,
E)
Proof.
We
that
Vlemma

S
is
vertex
cover
by
lemma
1.cover
The
only
Lemma
2.
If
S

VA,
isB
a
of
graph
G(V,
E),
then
V

Sisthat
isa
an
INDEPENDENT-S
B.
Since
A,
B

/
V

S,
we
have
S.
As
A
and
B
are
connected
Proof.
The
proof
is
actually
similar
to
previous
lemma.
Let
us
assume
that
V

S
is
not
a
INDEPENDENT-S
Proof.
We
know
that
V
S
vertex
lemm
Proof.
The
proof
similar
to
previous
lemma.
Let
us
assume
that
V

S
is
not
a
INDEPENDENT-S
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPEND
ENT-SET
of
graph
G(V,
E),
then
V

S
is
a
VERTEX-COVER
of
the
Proof.
We
know
that

is
vertex
cover
by
lemma
1.
The
only
thing
that
remains
We
know
that
V

S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
Proof.
Proof.
We
We
know
know
that
that
V
V

SSINDEPENDENT-SET.
is
a
anot
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
only
only
thing
that
that
remains
remains
for
for
ng
that
for
us
to
prove
is
its
vertex
cover
lemma
1.
The
only
that
remains
us
tous
prove
is
its
V
Vlemma

S
S
is
islemma.
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
t
minimality.
minimality.
Suppose
Suppose
ENDENT-SET
problem.
Proof.
Let
us
assume
that
Visalemma.
Sforvertex
not
athe
VERTEX-COVER.
Therefore,
there
are
two
ver
Proof.
Let
us
assume
aisProof.
VERTEX-COVER.
Therefore,
there
are
two
vertices
Ais
w
that
Vremains

Sby
is
a vertex
cover
by
lemma
The
only
thing
that
remains
for
us
to
prove
is
its
Proof.
The
proof
is
actually
similar
to
previous
Let
usand
that
VA,
B
SVTher
is
no
Proof.
Proof.
The
The
proof
proof
isis
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
Let
Let
us
The
assume
assume
proof
that
isminimum
actually
V
V

S
Snot
similar
not
not
aassume
athing
INDEPENDENT-SET.
to
INDEPENDENT-SET.
the
previous
lemma.
Vcontradiction.
thing
S
isSV
not
minimum
cover.
Then,
there
is
another
vertex
cover
S
minimality.
Suppose
contradiction.
Therefore
Vfor

is
an
Proof.
We
know
that

S
is
vertex
cover
by
The
only
thing
that
remains
for
u
VThe

S
is1.
not
minimum
vertex
cover.
Then,
there
isvertex
another
vertex
cover
VV

minimality.
Suppose
INDEPENDENT-SET
V

S
is
not
cover.
Then,
there
minimality.
Suppose
graph
G(V,
E)
oof
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V

S
is
athat
INDEPENDENT-SET.

STherefore,
is1.
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
INDEPENDENT-SET.
This
is
avertices
Therefore
V

S
is
anot
Proof.
us
assume
V
1.
Sis
is
athere
VERTEX-COVER.

S
aaTherefore,
vertex
cover
by
lemma
1.
only
thing
that
for
us
to
prove
its
Therefore,
there
are
two
vertices
A,
B

VSS

S
and
there
an
edge
connecting
A
B.
Since
V
V

Sis
is
not
minimum
vertex
cov
minimality.
Suppose
and
there
are
two
A,
B

S
there
is
an
edge
connecting
A
B.
Since
A,
B

ma
The
only
thing
that
remains
us
to
prove
is
its
Therefore,
there
two
vertices
A,
B

S
there
is
an
edge
connecting
A
B.
Since
A,
B
that
Let
and
vertices
and

V
isisis
an
INDEPENDENT-SET
of
graph
G(V,
E),
then
Vremains

Sand
is
ais
VERTEX-COVER
of
for
us
to
prove
isare
its
minimality.
Suppose

is
not
minimum
vertex
cover.
Then,
V

S
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V

S
where
ty.
Suppose
emains
for
us
to
prove
is
its
V
V

S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
there
is
is
another
another
vertex
vertex
cov
co
minimality.
minimality.
Suppose
Suppose
Proof.
Let
us
assume
that
V

S
is
not
a
VERTEX-COVER.
Therefore,
there
are
two
A,
B

/
V
S
the
.
there
are
two
vertices
A,
B

/
V

another
vertex
cover
V

S
where
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V

S
where
|V
|V

S
S
|
|
<
<
|V
|V

S|,
S|,
which
which
implies
implies
that
that
|S
|S
|
|
>
>
|S|.
|S|.
By
By
lemma
lemma
2,
2,
S
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
a

and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B

V
minimum
S
is
not
minimum
vertex
cover.
Then,
there
is|S|.
another
vertex
cover
VA,

S
where
ppose
ySsimilar
to
the
previous
lemma.
Let
us
assume
that
V

S
not
aedge
INDEPENDENT-SET.
Therefore,
there
two
vertices
A,
B
V

S
and
there
is
an
edge
connecting
A
and
Therefore,
Therefore,
there
there
are
two
two
vertices
vertices
A,
A,
B
B

V
Vare

S
Sedge
and
there
there
Therefore,
is
is
an
an
edge
edge
there
connecting
connecting
are
two
A
A
and
and
B.
A,
Since
Since
B
set.
VA,
A,

B
B

and
VVis

ther
S,
S,
|V

SB
|are
<
|V

S|,
which
implies
that
|S
|connecting
>
By
lemma
2,
S
is
an
independent
Sini
V

is
minimum
cover.
Then,
there
isthat
another
vertex
cove
minimality.
Suppose
|V

S
|//B
<1.
|VThe

S|,
which
implies
that
|Sby
| isan
>
|S|.
By
lemma
2,
is
an
independent
set.
Therefore,
S
vertex

|V
S
|S
<
|V

S|,
which
implies
that
|S
|vertices
>
|S|.
By
lemma
2,
S
an
and
re
are
two
vertices
A,

V
S
there
is
an
A
and
B.
B
V

S,
is
not
vertex
cover.
Then,
there
is
another
vertex
cover

SSince
where
and
there
is
an
connecting
A
and
B.
Since
A,
B
/aTherefore,
VS|S|.
S,
we
S
is
not
minimum
vertex
cover.
Then,
there
is
another
cover
VV

S
we
have
A,
B
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
aisVVB.
VERTEX-COVER.
This
|V
|
<
|V

S|,
which
implies
|S
|aconnected
>
By
le
and
vertex
ertex
cover
by
lemma
only
thing
that
remains
for
us
to
prove
is
its
we
have
A,

S.
As
A
B
are
connected
edge,
we
note
that
S
is
not
ais
VERTEX-COVER.
This

an
S

over.
Then,
there
is
another
cover
V

where
we
have
A,
B

/S
S.
As
A
and
B
are
connected
by
edge,
we
note
that
S
is
not
aais
VERTEX-COVER.
there
is
another
vertex
cover
not
where
, where
which
implies
that
cover
and
Theorem
1.
If

V
is
a
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then

S
is
a
MIN-VERTEX
<
|V

S|,
which
implies
that
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
not
vertex
V

S
where
|V
|V

S
S
|
|
<
<
|V
|V

S|,
S|,
which
which
implies
implies
that
that
|S
|S
|
|
>
>
|S|.
|S|.
By
By
lemma
lemma
2,
2,
S
S
an
an
independent
independent
set.
set.
The
Th
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,
B

S.
As
A
and
B
are
an
the
S,
we
have
A,
B

S.
As
A
and
B
are
connected
dependent
set.
Therefore,
is
not
a
that
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
maximum
maximum
independent
independent
set.
set.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V

st
prove
the
following
two
lemmas.
by
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
contradiction.
Th
Proof.
The
proof
is
actually
similar
to
previous
lemma.
Let
us
assume
that

S
is
not
INDEPEND
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore

S|,
which
implies
that
|S
|we
>
|S|.
By
lemma
Sby
isan
an
independent
set.
Therefore,
is
not
ertices
A,A
Band
V
S
and
there
isB
an
edge
Aedge,
and
A,
Vnot

S,
have
A,
B

/connecting
S.
As
A
and
BS
are
connected
by
an
edge,
we
note
that
S Viscover.
not
aisTher
VER
we
we
have
have
A,
A,
B
BB
/

/cover.
S.
S.
As
As
A
A
and
and
B
are
are
connected
connected
by
an
edge,
we
have
we
note
note
that
that

/is
S.
S
S
is
As
is
not
not
A
and
amaximum
aSThis
VERTEX-COVER.
VERTEX-COVER.
Ban
are
This
by
This
isis
edg
aS
aS
maximum
independent
set.
This
iswe
aimplies
contradiction.
Therefore
VB
S
is
minimum
vertex
|V

S
<
|V

S|,
which
that
|S
|
>
|S|.
By
lemma
2,
S
is
independent
set.
maximum
independent
set.
This
is2,
avertices
contradiction.
Therefore
V

S
isthe
the
minimum
vertex
cover.

are
t
aS.
VERTEX-COVER.
Therefore,
there
two
A,
B
/we
VSince

SB
maximum
independent
set.
This
a
contradiction.
Therefore

S an
the
that

/by
As
are
connected
by
an
edge,
note
that
isB.
not
aA,
VERTEX-COVER.
This
isaconnected
aminimum
implies
that
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
by
an
edge,
we
note
S
is
an
INDEPENDENT-SET.
This
implies
that
|S
|
>
|S|.
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
contradiction.
Therefore
V

S
is
an
INDEPENDENT-SET.
maximum
independent
set.
is
a
contradiction.
Ther
minimum
vertex
Then,
there
is
another
vertex
cover
V

S
where
.
By
lemma
2,

is
an
independent
set.
Therefore,
is
not
a
incontradiction.
Therefore
V
S
is
an
INDEPENDENT-SET.
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
contradiction.
Therefore
V

S
is
an
INDEPENDENT-SET.
of
the
graph
G(V,
E).
m
independent
set.
This
is
a
contradiction.
Therefore
V

S
is
the
minimum
vertex
cover.
nt
set.
Therefore,
S
is
not
a
maximum
maximum
independent
independent
set.
set.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V

S
S
is
is
the
the
minimum
vertex
vertex
co
co
an
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
is
a
T.
This
is
a
contradiction.
Therefore
V

S
is
a
minimum
vertex
cover.
a contradiction.
Therefore
Vedge,

SSSwe
is
the
minimum
vertex
cover.
VERTEX-COVER.
Therefore,
there
are
two
vertices
A,
Band

Sminimum
and
there
isTherefore
ancover.
edge
A
and B. vertex
Since A,
VERTEX-COVER.
VER
graph
G(V,
E),
then
V
SisisVTherefore
is
an
INDEPENDENT-SET
of
the
This
amaximum
contradiction.
V
SE),
the
vertex
and
Bof
are
connected
by
an
note
that
SThis
is
not
athen
VERTEX-COVER.
This
avertex
Therefore

S
isabove
antwo
INDEPENDENT-SET.
contradiction.
contradiction.
Therefore
Therefore
Vcontradiction.
V

an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
contradiction.
S
an
me
that
Vis

isBy
not
aINDEPENDENT-SET.
VERTEX-COVER.
Therefore,
are
vertices
A, conclude
B

/V
V
Sis
independent
set.
isVisVathere
contradiction.
Therefore
Visconnecting
S
isthat
the
minimum
covB
B.
Since
B

/isS
Vis

S,
we
have
A,
S.
As
A
B
are
connected
isset.

From
From
the
the
above
theorem,
we
we
conclude
that
athe
aINDEPENDENT-S
MIN-VERTEX-CO
MIN-VERTEX-CO
SThis

an
INDEPENDENT-SET
of
graph
G(V,
V
Stheorem,
athe
VERTEX-COVER
ofeasily
Therefore
V
dependent
is
anminimum
.endent
This
contradiction.
Therefore

S
is
the
minimum
vertex
cover.
set.
This
aVB
contradiction.
Therefore
is
is
minimum
cover.
VERTEX-COVER.
aaA,
contradiction.
Therefore

S
is
the
minimum
vertex
cover.
hat
|SVis
|V
>
|S|.
lemma
2,
SS.
isis
an
independent
set.
Therefore,
not
a note
herefore

SS
the
vertex
cover.
From
the
above
theorem,
we
conclude
that
a
MIN-VERTEX-COVER
can
be
constructed
if
m
vertex
cover.
From
the
above
theorem,
we
conclude
that
a
MIN-VERTEX-COVER
can
be
easily
constructed
ifwc
VERTEX-COVER.
From
the
above
theorem,
we
conclude
that
a
MIN-VERTEX-COVER
we
have
A,
B

/
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
VERTEX-COVER
Theorem
1.We
Sknow

ishave
aBVcontradiction.
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then

SifVconclude
iswe
acan
MIN-VERTEX-COV
From
the
above
theorem,
we
ausconstru
MIN-V

Sabove
is
an theorem,
INDEPENDENT-SET.
Theorem
1.
IfIfwe
S

VVSisthat
is
MAX-INDEPENDENT-SET
graph
E),
then
VVthen

S
is
aremains
MIN-VERTEX-COV
Theorem
1.
Ifwe

is
MAX-INDEPENDENT-SET
of
graph
G(V,
E),

S
isbe
athat
MIN-VERTE
ea)an
connecting
AMIN-VERTEX-COVER
and
B.
Since
A,

/V
VSais

S,
we
have
A,
B by
V of
S.
As
A
and
B
are
connected
INDEPENDENT-SET.
This
aa2.
Therefore
that
S we
is
aG(V,
Proof.
V
S
is
a
vertex
cover
lemma
1.
The
only
thing
that
for
to
pro
the
conclude
that
a
MIN-VERTEX-COVER
can
be
easily
constructed
have
a
From
From
the
the
above
above
theorem,
theorem,
we
we
conclude
conclude
that
a
a
MIN-VERTEX-COVER
MIN-VERTEX-COVER
can
be
easily
easily
constru
be
easily
constructed
if
a
onclude
that
a
can
be
easily
constructed
if
have
a
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
Lemma
If

V
is
a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPEN
Lemma
2.
If
S

a
VERTEX-COVER
of
graph
G(V,
E),
then
V

S
is
an
INDEPENDENT
contradiction.
Therefore
V

S
is
the
minimum
vertex
cover.
oveTheorem
theorem,
weIfthat
that
aabove
MIN-VERTEX-COVER
can
beV easily
constructed
if
we
a E),
Theorem
1.
If graph
S is
can
Vwe
is
a easily
MAX-INDEPENDENT-SET
then Vconstruc
Sthen
iso
Theorem
1.
1.
Theorem
1.
Ifconclude
SScan

V
V
isiseasily
aTherefore
athe
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
graph
G(V,
G(V,
E),
E),
IfaififVERTEX-COVER
Swe
then
then
have
V VVisof

a graph
S
MAX-INDEPENDENT-SET
S isishave
aaG(V,
MIN-VERTEX-COVER
MIN-VERTEX-COVER
MAX-INDEPENDENT-SET.
From
conclude
a Sis
MIN-VERTEX-COVER
can
be easily
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
contradiction.
Vtheorem,

S
an
INDEPENDENT-SET.
fm,

Vof
MAX-INDEPENDENT-SET
G(V,
E),
then

m,
we
conclude
ahave
MIN-VERTEX-COVER
can
be
easily
constructed
2.
Ifgraph
Sthat
then
V
we
conclude
that
a
MIN-VERTEX-COVER
be
constructed
of
the
graph
G(V,
E).
MAX-INDEPENDENT-SET.
the
graph
G(V,
-VERTEX-COVER
be
constructed
ifofLemma
we
aof
of
graph
G(V,
E).
eSthat
SVis2.
isaminimality.
an
INDEPENDENT-SET.
This
ishave
a contradiction.
Therefore
V INDEPENDENT-SET
aaisS another
is a of graph
Vgraph
G(V,
S Sof
isisE),
not
minimum
vertex
cover.
Then,
there
vertexG(V,
cover
V S
Suppose
DEPENDENT-SET.
sily
constructed
we
aof
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
Lemma
Ifnot
S1the
an
V
is
aE).
VERTEX-COVER
graph
G(V,
E),
VisaG(V,
MIN-VERTEX-COVER
SweE).
ishave
an
ofE),
the
E),
then
S
isif
INDEPENDENT-SET
of
the
graph
G(V,
E)
graph
G(V,
E)
previous
lemma.
Let
us
assume
that
V

not
a
INDEPENDENT-SET.
NDENT-SET.
MAX-INDEPENDENT-SET
of
graph
then
V

S
is
a
MIN-VERTEX-COVER
the
G(V,
E).
of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
of
the
graph
MAX-INDEPENDENT-SET.

We
say
that
problem
X
is
reducible
to
problem
Y
assume
that
VMIN-VERTEX-COVER
S
Therefore,
arehave
two2,vertices
A,independent
B
/ V S set. Therefore, S
G(V,
E).G(V,
T.
graph
G(V,
E)there
T.
is not a VERTEX-COVER.

nclude
that
a Theorem
can
be easily
constructed
if we
a SG(V,
|V
Sis
|an
< |V
If connecting
S|,
which
that
|S
| >A,
|S|.
By
lemma
is an
graph
E)
In
In
the
the
beginning
beginning
of
of
this
this
section,
section,
we
we
assume
assume
we
know
know
that
that
MIN-V
MIN-V
1.
S

V
is
aimplies
MAX-INDEPENDENT-SET
ofS,
graph
E),
then
V we

S
aus
MIN-VERTE
V edge
of
SProof.
and
there
edge
and
B.
Since
B
B
V1.

Proof.
We
know
that

Sthis
is
aA
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
toisprove
prove
We
know
that
VV

S
is
aan
vertex
cover
by
lemma
The
only
thing
that
remains
for
to
is
Proof.
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
pis
InProof.
beginning
of
section,
we
assume
we
know
that
MIN-VERTEX-COVER
is
aisVaNP-hard
probl
Inthe
the
beginning
of
this
section,
we
assume
we
know
that
MIN-VERTEX-COVER
isis
NP-hard
prob
VER
graph
G(V,
E),
then
INDEPENDENT-SET
of
the
In
the
beginning
of
this
section,
we
assume
we
know
that
MIN-VERTE
n
connecting
A
and
B.
Since
A,
B

/
V

S,
we
have
A,

S.
As
A
and
B
are
connected
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that

S
not
aits
IN
In
the
beginning
of
this
section,
we
assume
we
know
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V

S
not
a
INDEPE
Proof.
We
know
that
V

S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
rema
Proof.
Proof.
Proof.
We
We
know
know
that
that
V
V

S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
We
only
only
know
thing
thing
that
that
that
V

remains
remains
S
is
a
vertex
for
for
us
us
cover
to
to
prove
prove
by
lemm
is
is
maximum
independent
set.
This
is
a
contradiction.
Therefore
V

S
is
the
minimum
vertex
cover.
e
beginning
of
this
section,
we
assume
we
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
It
is
In
In
the
the
beginning
beginning
of
of
this
this
section,
section,
we
we
assume
assume
we
we
know
know
that
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
a
a
NP-h
NP-h
its
X-COVER
is
a
NP-hard
problem.
It
is
we
assume
we
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
It
is
good
good
to
to
know
know
as
as
many
many
NP-hard
NP-hard
problem
problem
as
as
possible.
possible.
This
This
is
is
necessary
necessary

of
the
graph
G(V,
E).
ow
that
V

S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
nected
by
an
edge,
we
note
that
S
is
not
a
VERTEX-COVER.
This
is
a
Proof.
The
proof
isThis
actually
similar
to
the
Let
us
ning
this
section,
we
assume
weS
know
that
MIN-VERTEX-COVER
isisknow
athat
NP-hard
problem.
It
is lemma.
VINDEPENDENT-SET.

Sthere
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
SVassu
wh
minimality.
Suppose
V

is
not
vertex
cover.
Then,
there
is
vertex
V

S
wh
Suppose
V
Sare
isminimum
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover

minimality.
Suppose
good
to
know
as
many
NP-hard
problem
as
This
isthere
necessary
so
that
ifprevious
encounter
aA
proble
is
aofminimality.
VERTEX-COVER
of
graph
G(V,
E),
then
V

Swe
isLet
an
INDEPENDENT-SET
of
the
In
the
beginning
of
this
section,
assume
we
that
MIN-VERTEX-COVER
isnew
a
NP-ha
good
know
as
many
NP-hard
problem
as
possible.
necessary
so
that
ifwe
we
encounter
aV
new
prob
good
to
know
as
NP-hard
problem
as
possible.
This
iscover
necessary
so
tha
Proof.
The
proof
isto
actually
similar
to
the
previous
lemma.
us
assume
Vis

not
aproblem
INDEPENDENT-SET.
us
assume
that
V

S
is
not
athere
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
ais
contradiction.
Therefore
Vedge

Sthat
is
aifA
Therefore,
two
A,
B

Swe
and
there
is
an
connecting
B.
sV
section,
we
assume
we
know
that
MIN-VERTEX-COVER
is
NP-hard
problem.
Itanother
is
Since
section,
we
assume
we
know
that
MIN-VERTEX-COVER
aaas
NP-hard
problem.
It
is
good
to
know
as
many
NP-hard
problem
as
possible.
This
Therefore,
two
vertices
A,
B

Vmany

S
and
is
an
edge
connecting
and
B.
A
where
w
MIN-VERTEX-COVER
is
apossible.
NP-hard
problem.
Itpossible.
is

S
aencounter
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
V

Sany
is
not
minimum
cover.
Then,
there
another
minimality.
Suppose
V
Vto

S
S
is
isare
not
not
minimum
minimum
cover.
cover.
Then,
Then,
there
there
is
another
VS

S
vertex
vertex
is
not
cover
minimum
cover
VVis

vertex
Sit
Sand
where
cov
minimality.
minimality.
Suppose
Suppose
minimality.
Suppose
know
many
problem
as
This
isvertices
necessary
so
that
iftwo
encounter
ais
new
X,
we
so
R
isthat
aisas
NP-hard
problem.
It
is
good
to
know
know
as
as
many
many
NP-hard
NP-hard
problem
problem
as
possible.
possible.
This
is
isanother
necessary
so
that
if
we
we
encounter
encounter
aver
ano
nS
n
is
vertex
vertex
tblem
if
we
aThis
new
problem
X,
we
possible.
is
necessary
so
that
ifthat
we
encounter
a>
new
problem
X,
we
can
can
use
use
of
of
the
the
NP-hard
NP-hard
problems
problems
that
that
we
we
know,
know,
reduce
reduce
it
to
to
probl
prob
NP-hard
vertex
This
good
any
necessary
V
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V

S
where
uppose
DEPENDENT-SET.
Therefore,
there
are
vertices
A,
B

S
and
there
is
an
edge
many
NP-hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
|V

S
|
<
|V

S|,
which
implies
that
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
no
|V

S
|
<
|V

S|,
which
implies
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
|V

S
|
<
|V

S|,
which
implies
that
|S
|
|S|.
By
lemma
2,
S
is
an
independent
set.
Therefore,
can
use
any
of
the
NP-hard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
good
to
know
as
many
NP-hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
ne
can
use
any
of
the
NP-hard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
can
use
any
of
the
NP-hard
problems
that
we
know,
reduce
it
to
problem
X,
From
the
above
theorem,
we
conclude
that
a
MIN-VERTEX-COVER
can
be
easily
constructed
if
w
Therefore,
there
are
two
vertices
A,
B

S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B

S,
n
edge
connecting
A
and
B.
Since
A,
B

S,
note
VER.
we
have
A,
B

/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEX

hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
Proof.
We
know
that
V

S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
pS

hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
can
use
any
of
the
NP-hard
problems
that
we
know,
reduc
we
have
A,
B

/
S.
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
VERTEX-COV
we
assume
we
know
that
MIN-VERTEX-COVER
is
a
NP-hard
problem.
It
is

his
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
S
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V

S
where

S
|
<
|V

S|,
which
implies
that
|S
|
>
|S|.
By
lemma
2,
S
is
an
independent
s
|V
|V

S
S
|
|
<
<
|V
|V

S|,
S|,
which
which
implies
implies
that
that
|S
|S
|
|
>
>
|S|.
|S|.
By
By
lemma
lemma
|V

S
2,
2,
|
S
<
S
|V
is
is
an
an

S|,
independent
independent
which
implies
set.
set.
Therefore,
that
Therefore,
|S
|
>
S
S
|S|.
is
is
not
not
By
a
le
a
ny
of
the
NP-hard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NP-hard.
|V

counter
a
new
problem
X,
we
can
can
use
use
any
any
of
of
the
the
NP-hard
NP-hard
problems
problems
that
that
we
we
know,
know,
reduce
reduce
it
it
to
to
problem
problem
X,
X,
and
and
thus
thus
prove
prove
that
that
previous
lemma.
Let
us
assume
that
V

S
is
not
a
INDEPENDENT-SET.
and
thus
prove
that
X
is
also
NP-hard.
ms
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NP-hard.
1contradiction.
1have

S|,
which
that
|S
| know,
>
|S|.
By
2,
S
isedge,
an
independent
SNP-hard.
isYYX,
not
we
A,
B

/problem
S.
As
and
B
connected
byaan
edge,
weisthat
note
NP-hard
problems
that
we
reduce
to
problem
X,that
and
thus
prove
Xare
is
also
maximum
independent
set.
This
islemma
contradiction.
Therefore
VXA

Sthat
isTherefore,
the
vertex
cover.
maximum
independent
set.
This
is
aait
contradiction.
Therefore
VX

S
the
minimum
vertex
cover.
maximum
independent
set.
is
aV
Therefore
Vis

Sto
is
theis
minimum
vertex
cover.
We
We
say
say
that
problem
isset.
reducible
reducible
to
to
problem
problem
can
use
any
of
the
NP-hard
problems
we
know,
reduce
it
problem
and
thus
prove
X
11
1not
MAX-INDEPENDENT-SET.
we
have
A,
Bimplies
/we
S.
As
A
and
BTherefore
connected
by
we
note
that
S
is
not
aminimum
VERTEX-COVER.
This
aV
note
that
S
is
aand
VERTEX-COVER.
contradiction.
Therefore

SINDEPENDENT-SET.
is
an
INDEPENDENT-SET.
dehe
problems
that
we
know,
reduce
to
problem
X,
and
thus
prove
that
X
also
NP-hard.

S
is1
not
minimum
vertex
cover.
Then,
there
another
vertex
cover
minimality.
Suppose
We
say
that
problem
X
is
reducible
to
problem
Yathat
problems
that
know,
reduce
ititare
to
problem
X,
and
thus
that
X
isisis
also
NP-hard.
We
say
problem
X
is
reducible
to
problem
Y
contradiction.
VThis
Sis
isaNP-hard.
an
lem
possible.
This
isthat
necessary
so
that
ifThis
we
encounter
new
problem
X,
we
We
say
that
problem
XV
is
reducible
to
problem
Yprove
uce
itasto
problem
X,
thus
prove
that
X
is
also

90

J.I. Gunawan

From the above theorem, we conclude that a MIN-VERTEX-COVER can be easily


constructed if we have a MAX-INDEPENDENT-SET.
In the beginning of this section, we assume we know that MIN-VERTEX-COVER
is a NP-hard problem. It is good to know as many NP-hard problem as possible. This
is necessary so that if we encounter a new problem X, we can use any of the NP-hard
problems that we know, reduce it to problem X, and thus prove that X is also NPhard.

3. How to Proceed

Suppose we already know that a problem is unsolvable (i.e. any known algorithm will
not solve this problem in time). In competition, it is impossible to complain that This
is unsolvable, can you eliminate this problem? to the judges, since the judges believe
How
How to
to proceed
proceed
they have a solution. Such a request is absurd when there are already several contestants
have
that problem.
Also,this
in aproblem
major competition
(e.g. ACM International
any
algorithm
will
in
s unsolvable
unsolvable (i.e.
(i.e. who
any known
knownsolved
algorithm
will not
not solve
solve
this
problem
in
Collegiate
Programming
Contest
World
Finals,
IOI),
it
is
unlikely
that the judges have
omplain that
complain
that "This
"This isis unsolvable,
unsolvable, can
can you
you eliminate
eliminate this
this problem?"
problem?"
incorrect
solution.
yy have
have aa solution.
solution. Such
Such aa request
request isis absurd
absurd when
when there
there are
are already
already

blem. Also,
oblem.
Also, inin aa major
major competition
competition (e.g.
(e.g. ACM
ACM International
International Collegiate
Collegiate
How to
isis unlikely
unlikely that
that the
the judges
judges have
have incorrect
incorrect solution.
solution. 3

3.1. Approximation

proceed

Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this pro
time).InInreal
competition,
it iscannot
impossible
to optimal
complainsolution,
that "This
is unsolvable,
can solution
you eliminate this pr
life, when we
find the
we can
try to find the
to can
thethat
judges,
since
the
judges
believe
they
a solution.
request
is absurd
try
to
nd
the
solution
that
isis close
to
the
optimal
all solution,
solution, we
we
can
try
toclose
nd
thethe
solution
that
close
to have
the
optimal
is
to
optimal
solution.
More
specifically,
we Such
try to afind
a solution
that iswhen there are
several
contestants
who
have
solved
problem.
Also, insolution
a major for
competition
(e.g. ACM
isis not
larger
(where
>
1)
the
optimal
not
than
(where
a minimisation
prob-International C
a solution
solution that
that
not
larger than
than
(where
>that
1)) times
times
theoptimal
optimal
lem. The Contest
mostalgorithm
common
Ithat
found
textbooks
the 2-approxProgramming
World approximation
it algorithm
is unlikely
theinjudges
haveisincorrect
solution.
most
approximation
IFinals,
in
isis the
most common
common
approximation
algorithm
I found
foundIOI),
in textbooks
textbooks
the
MIN-VERTEX-COVER
problem,
which
means that the algorithm will not
blem,
that
algorithm
more
twice
blem, which
which means
meansimation
that the
the
algorithm will
will not
not choose
choose
more than
than
twice
choose
more than
twice the
number
of3.1
vertices
than the optimal solution. However, apution.
problems
rarely
occur
in
competitive
lution. However,
However, approximation
approximation
problems
rarely
occur
in
competitive
Approximation
proximation
problems
rarely
occur
in
competitive
programming
(especially IOI). One
eason isis because
reason
because to
to create
create this
this kind
kind of
of problem,
problem, the
the judges
judges have
have to
to
In
real
life,
when
we
cannot
nd
the
optimal
solution,
we
can
try
to
nd
the solution
of
the
reason
is
because
to
create
this
kind
of
problem,
the
judges
have
to knowthat
theis close to the
y that
that the
the contestants
contestants solution
solution isis indeed
indeed -approximation.
-approximation. However,
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than

(where

> 1) times the


optimal
solution
in
order
to
verify
that
the
contestants
solution
is
indeed
-approximaee (or
(or takes
takes aa long
long time).
time). Since
Since this
this approach
approach isis not
not really
really suitable
suitable for
for
tion.
generating
the optimal
solution
is impossible
(or takes
a long time).
solution
forHowever,
a minimisation
problem.
The most
common
approximation
algorithm
I found in textbook
this
in
this approach
approach
in detail.
detail.
Since this approach
is not really suitable
forwhich
competitive
I willwill
notnot
dis-choose more th
2-approximation
MIN-VERTEX-COVER
problem,
means programming,
that the algorithm
cuss this
in detail.
the number
of approach
vertices than
the optimal solution. However, approximation problems rarely occur in com
3.2
3.2 Pruning
Pruning
programming (especially IOI). One of the reason is because to create this kind of problem, the judges
know
the optimal
solution
in order
to verifyProgramming
that the contestants solution is indeed -approximation. H
programming
problems.
In
International
Collegiate
programming
problems.
In ACM
ACM
International
Collegiate
Programming
3.2. Pruning
the optimal
solution isto
impossible
takes aof
m
on
the
count
number
m II (Robots
(Robotsgenerating
on Ice)
Ice) required
required
the contestant
contestant
to
count the
the(or
number
oflong time). Since this approach is not really sui
I will n.d.),
not
discuss
approach
ICPC
Finals
problem
which
isis known
to
ICPC World
Worldcompetitive
Finals 2010
2010programming,
problem statement
statement
n.d.),
whichthis
known
to in detail.
ossible
the
isis to
prune
ossible paths
paths isis impossible,
impossible,
the solution
solution
for
this problem
problem
toprogramming
prune
This approach
is
usefulfor
in this
some
competitive
problems. In ACM International
Collegiate
Programming
Contestn.d.).
(ICPC)
World
Finals
ICPC
World
2010
If
at
lll possible
ICPC
World Finals
Finals
2010 Solutions
Solutions
n.d.).
If
at
possible paths
paths (ACM
(ACM
3.2 Pruning 2010, problem I (Robots
on Ice) points,
required
thewe
contestant
tothe
count
theand
number of Hamiltonian Paths with
visit
unvisited
then
can
path
visit the
the rest
rest of
of the
the
unvisited
points,
then
we
can prune
prune
the
path
and
This
approach
is
useful
in
some
competitive
programming
ACMwhich
International
Collegiate Prog
constraints
(ACM
ICPC
World
Finals
2010
problem
statement,Inn.d.),
is known
ery suitable
very
suitable for
for IOI.
IOI. Usually,
Usually, IOI
IOI problems
problems require
require deep
deep analysis
analysis from
fromproblems.
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
count the nu
to
be
a
NP-hard
problem.
While
finding
all
possible
paths
is
impossible,
the
solution
cepted by
ccepted
by only
only "hacking"
"hacking" aa complete
complete search
search algorithm.
algorithm. Therefore,
Therefore, we
we
Hamiltonian Paths with constraints (ACM ICPC World Finals 2010 problem statement n.d.), which is k
be a NP-hard problem. While nding all possible paths is impossible, the solution for this problem is
the exponential algorithm we use to nd all possible paths (ACM ICPC World Finals 2010 Solutions n.d
nding
nding Small
Small Constraints
Constraints
some point we know that it is impossible to visit the rest of the unvisited points, then we can prune the p
backtrack
immediately.
However,
it is not(e.g.
very N
suitable
for IOI. Usually, IOI problems require deep analy
hh large
isis impossible
to
exponentially
large N
N that
that
impossible
to solve
solve
exponentially
(e.g.
N>
> 50).
50).

.1
.1 Approximation
Approximation

1)
theto
optimal
tion.
However,
approximation
problems
rarely
occur
injudges
competitive
intimes
isthe
the
isthis
because
create
this
kind
of
problem,
the
judges
have
to
know
the
optimal
solution
in
order
verify
that
the
solution
isinco
in
know
the
solution
to
verify
that
the
contestants
solution
issolution
indeed
-approximation.
Howev
nd
oftextbooks
problem,
judges
have
to
In
real
life,
when
we
cannot
nd
the
optimal
solution,
we
try
toto
nd
the
that
istime).
to
the
optim
ming
Contest
World
Finals,
IOI),
itin
isorder
Programming
unlikely
that
the
Contest
World
have
Finals,
incorrect
IOI),
solution.
it(or
is
unlikely
thatfor
the
judges
have
generating
the
optimal
solution
impossible
(or
takes
acan
long
time).
Since
this
approach
isclose
not
really
suitabl
generating
the
optimal
solution
is
impossible
takes
acontestants
long
Since
this
ap
deed
-approximation.
However,
optimal
solution
is
impossible
(or
takes
long
time).
Since
this
approach
is
not
really
suitable
approach
isoptimal
not
really
suitable
for
competitive
programming,
Iaiswill
not
discuss
this
approach
in
detail.
in
textbooks
is
the
ason
is
because
to
create
this
kind
of
problem,
the
judges
have
to
oose
more
than
twice
the
contestants
solution
is
indeed
-approximation.
However,
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
af
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
approach
is
not
really
suitable
ndeed
-approximation.
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than

(where

>
1)
times
the
optim
competitive
I will notindiscuss
this approach
competitive
programming,
I 3.1
will in
notdetail.
discuss this approach in detail.
approach
is Inot
suitablethis
forapproach
gramming,
willreally
not programming,
discuss
detail.
Approximation
oose
more
than
twice
that
the
contestants
solution
is
indeed
-approximation.
However,
occur
in
competitive
akes
a
long
time).
Since
this
approach
is
not
really
suitable
for
competitive
willdetail.
not discussalgorithm
this approach
in detail.
competitive
I problem.
will
not
discuss
this approach
approach
is not
suitable for
solution
for really
aprogramming,
minimisation
The programming,
most
commonI in
approximation
I found
in textbooks is th
3.1
Approximation
3.1
Approximation
3.2
Pruning
occur
in in
competitive
adetail.
long
Since
approach
isproblem,
not
really
suitable
for
,(or
thetakes
judges
havetime).
toInMIN-VERTEX-COVER
real
life,this
when
we Understanding
cannot
nd
the
optimal
solution,
we
can
try
to
nd
the
solution
is twic
clos
pproach
2-approximation
which
means
that
the
algorithm
will
not
choose
than
Unsolvable
Problem
91 morethat
3.2
Pruning
3.2
Pruning
3.2 solution,
Pruning
,his
judges
have
to
, the
when
we
cannot
nd
the
optimal
In
real
life,
we
when
can
try
we
to
cannot
nd
the
nd
solution
the
optimal
that
is
solution,
close
to
we
the
can
optimal
try
to
nd
the
sol
approach
in
detail.
oximation.
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than

(where

>
1)
ti
the
number
of
vertices
than
the
optimal
solution.
However,
approximation
problems
rarely
occur
in
competitiv
This approach is useful in some competitive
problems. In ACM
3.2 International
PruningCollegiate Prog
3.2programming
Pruning
oximation.
However,
More
specically,
we
try
to
nd
a
solution
solution.
that
More
is
not
specically,
larger
than
we

try
(where
to
nd

a
>
solution
1)
times
that
the
is
optimal
not
larger
than

not
really
suitable
for
solution
for
a
minimisation
problem.
The
most
common
approximation
algorithm
I
found
in
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programm
This
approach
useful
in
some
competitive
programming
problems.
In
ACM
Intern
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programming
for
this
problem
is
to prune
the
exponential
we
use
findkind
all possible
pathsthe
programming
(especially
IOI).
One of
the
reason
this
of contestant
problem,
havenut(
M
Collegiate
Programming
Contest
(ICPC)
World
Finals
2010,
problemis algorithm
Ibecause
(Robotsto
oncreate
Ice)torequired
the
to judges
count the
2 International
Pruning
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
Inte
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programmi
not
really
suitable
for
or
a
minimisation
problem.
The
most
solution
common
for
a
approximation
minimisation
algorithm
problem.
The
I
found
most
in
common
textbooks
approximation
is
the
algor
2-approximation
MIN-VERTEX-COVER
problem,
which
means
that
the
algorithm
will not
choose
Contest
(ICPC)
World
2010,
problem
I the
(Robots
on
required
the
contestant
count
the
numb
Contest
(ICPC)
World
Finals
2010,
problem
Iproblem
(Robots
on
Ice)
the
cont
rnational
Collegiate
Programming
(ACM
ICPC
World
2010
Solutions.
n.d.).
If
atIce)
some
we
know
that
it
isrequired
World
Finals
2010,
problem
I Finals
(Robots
on
Ice)
required
the
contestant
topoint
count
the
number
ofto
know
the
optimal
solution
in Finals
order
to
verify
that
contestants
solution
is
indeed
-approximation.
Howeve
he
contestant
to
count
the
number
of
3.2
Pruning
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
statement
n.d.),
which
is k
mming
problems.
In
ACM
International
Collegiate
Programming
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
con
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
ternational
Collegiate
Programming
mation
MIN-VERTEX-COVER
problem,
2-approximation
which
means
that
MIN-VERTEX-COVER
the
algorithm
will
not
problem,
choose
which
more
means
than
twice
that
algorithm
the
number
of
vertices
than
the
optimal
solution.
However,
approximation
problems
rarely
occu
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
which
is
know
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
state
ntestant
to
count
the
number
of
thsstatement
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
approach
is
not
really
suitable
em
n.d.),
which
is
known
to
be a NP-hard problem. While nding all possible paths is impossible, the solution for this problem isf
rogramming
problems.
In
ACM
International
Collegiate
Programming
obots
on
Ice)
required
the
contestant
to
count
the
number
of
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
2010
problem
sta
Hamiltonian
Paths
with
constraints
(ACM
ICPC
Finals
2010
problem
statement
n.d.),
which
is known
to
count
the
number
er
of competitive
vertices
than
the
optimal
solution.
the
number
However,
approximation
vertices
than
problems
optimal
rarely
solution.
occur
inproblems
competitive
approximation
prob
backtrack
immediately.
itof
ispossible
not
very
suitable
for
IOI.
Usually,
IOI
programming
(especially
IOI).
One
of
the
reason
is(ACM
because
to
create
this
kind
of Solutions
problem,
thp
be
athe
NP-hard
While
nding
all
paths
is
impossible,
the
solution
for
this
problem
issolutio
to
be
aHowever,
NP-hard
problem.
While
nding
all
possible
paths
isFinals
impossible,
the
tement
n.d.),
which
isproblem.
known
to
roblem.
While
nding
all
possible
paths
isuse
impossible,
the
solution
this
problem
isHowever,
to
prune
programming,
Iof
will
not
discuss
this
approach
inthe
detail.
eontestant
solution
for
this
problem
isalgorithm
to
prune
ICPC
World
Finals
2010
n.d
exponential
we
to
nd
allWorld
possible
paths
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
of
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
be
a
NP-hard
problem.
While
nding
all
possible
paths
is
impossible,
the
solu
be
a
NP-hard
problem.
While
nding
all
possible
paths
is
impossible,
the
solution
for
this
problem
is
to
pru
tatement
n.d.),
which
is
known
to
require
deep
analysis
from
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
ming
(especially
IOI).
One
of
the
reason
programming
is
because
(especially
to
create
this
IOI).
kind
One
of
of
problem,
the
reason
the
is
judges
because
have
to
to
create
this
kind
know
the
optimal
solution
in
order
to
verify
that
the
contestants
solution
is
indeed
-approxim
ICPC
World
Finals
2010
Solutions
n.d.).
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ICPC
World
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
tion
for
thiswe
problem
is we
toall
prune
World
Solutionspoints,
n.d.). If
at we can prune theFip
algorithm
usepoint
to nd
possible
(ACM ICPC
World
Finals
2010
Solutions
n.d.).
If atitpaths
some
know
that
is impossible
to visit
the Finals
rest of2010
the unvisited
then
CPC
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
legiate
Programming
paths
is
impossible,
the
solution
for
this
problem
is
to
prune
ICPC
World
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ICPC
World
Finals
2010
Solutions
n.d.).
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ution
for
this
problem
is
to
prune
hacking
a
complete
search
algorithm.
Therefore,
we
will
not
discuss
this
technique
optimal
solution
in prune
order
that
know
the
contestants
solution
solution
isorder
indeed
tocan
that
the
contestants
solution
is Ifintr
-approximation.
However,
generating
thethe
optimal
solution
is impossible
(or
takes
averify
long
time).
Since
this
approach
is analy
not
some
we
know
that
itsome
is
impossible
to
visit
the
of
the
unvisited
then
we
can
prune
the
path
point
we
know
that
itrest
isinimpossible
to
visitpoints,
the
rest
ofand
the
unvisited
points,
Finals
2010
Solutions
n.d.).
Ifverify
at
know
that
it backtrack
ispoint
impossible
to
rest
ofthe
the
unvisited
points,
then
we
prune
the
path
points,
then
we
can
thevisit
path
and
immediately.
However,
itoptimal
is
not
very
suitable
for
IOI.
Usually,
IOI
problems
require
deep
3.2
Pruning
legiate
Programming
ssible
paths
is
impossible,
the
solution
for
this
problem
is
to
prune
count
the
number
of
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
ble
paths
(ACM
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
in
detail.
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
d
Finals
2010
Solutions
n.d.).
If
at
g then
the
optimal
solution
impossible
(or
generating
takes
acan
the
optimal
time).
Since
solution
this
is
approach
impossible
(or
takes
reallyfor
asuitable
long
time).
fordeep
Since
thisa
competitive
programming,
Ilong
will
not
discuss
this
approach
inisIOI
detail.
immediately.
However,
it IOI.
isimmediately.
not
very
suitable
for
IOI.
Usually,
problems
require
analysis
backtrack
However,
it
is
not very
suitable
IOI.
Usually,
IOI
probl
webacktrack
canthe
prune
the
path
ediately.
However,
it deep
isisnot
very
for
Usually,
IOI
problems
require
deep
analysis
from
OI
problems
require
analysis
from
contestant.
Itand
is suitable
rare
that
we
get
Accepted
by
only
"hacking"
anot
complete
search
algorithm.
There
count
the
number
of
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
possible
paths
(ACM
),
which
is
known
to
he
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
backtrack
immediately.
However,
it get
is
not
very
suitable
for
Usually,
IOI pro
backtrack
immediately.
However,
itcan
is
not
very
for
IOI.
Usually,
problems
require
deep
analysis
fros
s,
then
we
can
prune
the
path
and
This
approach
is
useful
in
some
programming
problems.
In
ACM
International
Collegiate
ve
Ican
will
not
this
competitive
approach
in
programming,
I we
will
not
discuss
this
approach
inIOI.
detail.
the
contestant.
ItTherefore,
isdiscuss
rare
that
we
get
Accepted
by
only
"hacking"
aIOI
complete
search
algorithm.
Therefore
the
contestant.
Itdetail.
issuitable
that
can
Accepted
by only
"hacking"
aProgrammin
complete
blems
require
deep
analysis
from
It programming,
is rare
that
we
get
Accepted
by
only
arare
complete
search
algorithm.
Therefore,
we
mplete
search
algorithm.
we
will
not
discuss
this
technique
in"hacking"
detail.
),
which
is
known
to
isit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
problem
is
to
prune
itable
for
IOI.
Usually,
IOI
problems
require
deep
analysis
from
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
algorithm.
Therefore,
w
roblems
require
deep
analysis
from
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
o
will
notindiscuss
this technique
in detail.
discuss this technique in 3.2
detail. Pruning
ethis
search
algorithm.
Therefore,
we will not
technique
detail.
3.3.
Finding
Small
problem
is
todiscuss
prune
ry
for
IOI.
Usually,
IOIconstraints
problems
require
deep
fromin2010
n.d.).
If Paths
at
dSolutions
bysuitable
only
a Therefore,
complete
search
algorithm.
Therefore,
weFinals
will
not
discuss
thisanalysis
technique
detail.
will "hacking"
not
this
technique
in3.2
detail.
te
search
algorithm.
weConstraints
Hamiltonian
with
(ACM
ICPC
World
problem
statement
n.d.),
which
is
known
t
Pruning
3.2 Pruning
3.3
Finding
Small
Constraints
n.d.).
Ifand
atproblem.
epted
bythe
"hacking"
complete
Therefore,
we
nSolutions
prune
path
This aapproach
useful algorithm.
inall
some
competitive
problems.
In for
ACM
Collegia
be
aonly
NP-hard
Whileis search
nding
possible
paths isprogramming
impossible,
the
solution
thisInternational
problem is to
prun
3.3
Finding
Small
Constraints
3.3
Finding
Small
Constraints
3.3
Finding
Small
Constraints
ints
noach
prune
the
path
and
is
useful
in
some
competitive
programming
This
approach
problems.
is
useful
In
in
ACM
some
International
competitive
Collegiate
programming
Programming
problems.
In
ACM
Inte
e deep
fromContest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
coun
ICPC
World
Finals
2010
Solutions
n.d.).
IfNa
theanalysis
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
Suppose
there
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
Suppose
thereisis
an
NP-hard
problem
large

that
is
impossible
to
solve
expo3.3 Finding Small Constraints
3.3 Finding Small Constraints
e
deep
analysis
from
ICPC)
World
Finals
2010,
problem
I
Contest
(Robots
(ICPC)
on
Ice)
World
required
Finals
the
2010,
contestant
problem
to
count
I
(Robots
the
number
on
Ice)
required
of
the
co
rithm.
Therefore,
we
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
w
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
an
o
solve
exponentially
(e.g.
N
>
50).
nentially we
(e.g.
Sometimes
should
also look
formay
other
small
Sometimes
should also).look
for otherwe
small
constraints
that
help.
Forconstraints
example, a SUBSET-SUM
gs Small Constraints
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solv
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
rithm.
Therefore,
we
an
Paths
with
constraints
(ACM
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
ICPC
which
World
is
Finals
known
2010
to
problem
sta
be
a
NP-hard
problem.
While
nding
all
possible
paths
is
impossible,
the
solution
for
this
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSET-SUM
pro
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
exam
ve
exponentially
(e.g.
N
>
50).
hould
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSET-SUM
problem
backtrack
immediately.
However,
it isa SUBSET-SUM
notand
verywill
suitable
for
IOI.isUsually,
problems
fro5
For example,
SUBSET-SUM
problem
may help.
For
example,
problem
considered
an
NP-hard
probding
Small
Constraints
isathat
considered
an NP-hard
problem,
not be
solvable
with NIOI
= 100.
Whenrequire
we
aredeep
givenanalysis
the constr
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
exw
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSET-SUM
proble
olve
exponentially
(e.g.
N
>
50).
2
hard
problem.
While
nding
all
possible
be
a
paths
NP-hard
is
impossible,
problem.
While
the
solution
nding
for
all
this
possible
problem
paths
is
is
to
impossible,
prune
the
solu
ICPC
World
Finals
2010
Solu
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
considered
anwill
NP-hard
and
will
not100.
be
N
100.
When
we
are
given
constraint
isthat
considered
an
NP-hard
problem,
and
will
not
solvable
with
=the
100.
When
ample,
aiscontestant.
SUBSET-SUM
problem
NP-hard
problem,
and
will
not
beproblem,
solvable
with
Nsmall
=
When
wewith
are
given
thebe
constraint
that
not
be
solvable
with
. solvable
When
we
are
given
the
constraint
allNusing
thewe
It
is
rare
that
we
can
get
Accepted
by
only
a=problem
complete
search
algorithm.
Therefore,
When
are
given
constraint
alllem,
the and
elements
inside
the
array
are
(e.g.
[0, "hacking"
100]),
this
can
be that
solved
O(N
X )w
D
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
2
straints
that
may
help.
For
example,
a
SUBSET-SUM
problem
2
is
considered
an
NP-hard
problem,
and
will
not
be
solvable
with
N
=
100.
When
is
considered
an
NP-hard
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
th
2
example,
a
SUBSET-SUM
problem
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
ICPC
World
ential
algorithm
we
use
to
nd
all
possible
the
exponential
paths
(ACM
algorithm
we
use
to
nd
all
possible
paths
(ACM
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
pru
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dyna
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
so
nsan
we
given
the
constraint
that
the
elements
inside
the
array
are
small
(e.g.
),
this
problem
can
be
solved
using
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynamic
will
not
discuss
this
technique
in
detail.
beare
solved
using
O(N
X
)
Dynamic
Programming, where X is the upper bound of the elements inside the array. Even though the running
tim
2 can be
lltsolvable
constraints
that
example,
arest
SUBSET-SUM
problem
with
Nupper
100.
When
we
are
given
the
constraint
that
2 where
all
thepoint
elements
array
are
small
(e.g.
[0,
100]),
this
problem
all
the
elements
the
array
are
small
(e.g.
[0,
this
problem
can
solved
using
O(N
Xconstraint.
) Dynam
en
weknow
are
given
the
constraint
that
we
that
it=may
isX
impossible
to
visit
some
the
of
we
the
know
unvisited
itvery
points,
is
impossible
then
we
to
can
visit
prune
the
rest
the
of
path
the
and
unvisited
points
backtrack
immediately.
However,
it
not
suitable
for
IOI.
Usually,
IOI
problems
require
de
Programming,
X
isof
the
upper
bound
ofinside
the
elements
inside
array.
Even
though
the
running
time
o
Programming,
where
Xisthat
is
the
bound
of
thebe
elements
inside
the
array.
Even
help.
Dynamic
Programming,
where
100]),
isthe
the
upper
bound
of
the
elements
inside
solved
using
O(N
)inside
Dynamic
where
X
is
the
bound
ofFor
the
elements
inside
array.
Even
though
thestill
running
time
offor
the
y.
Even
though
the
running
time
the
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
fast
enough
the
given
2 constraint that
2can
ot
be
solvable
with
N
=
100.
When
we
are
given
the
ally
(e.g.
N
>
50).
0,
100]),
this
problem
be
solved
using
O(N
X
)
Dynamic
Programming,
where
X
is
the
upper
bound
of
the
elements
inside
the
array.
Eve
Programming,
where
X
is
the
upper
bound
of
the
elements
inside
the
array.
Even
though
the
running
time
of
e
solved
using
O(N
X
)
Dynamic
immediately.
However,
it
is
not
very
backtrack
suitable
for
immediately.
IOI.
Usually,
However,
IOI
problems
it
is
not
require
very
suitable
deep
analysis
for
IOI.
from
Usually,
IOI
pro
the
array.
Even
though
the
running
time
of
the
algorithm
is
exponential
to
the
size
of
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
algorithm
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Ano
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
fo
n
though
the
running
time
of
the
onential
size
the this
input,
the algorithm
is still
enough
the too
given
constraint.
nough
forto the
given
constraint.
Another
way
to of
apply
technique
is when
the fast
value
of N for
is Constraints
not
large
(e.g. NAnother
< 40). For example, whilt
3.3
Finding
2 Small
ally
(e.g.
N
>
50).
e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynamic
BSET-SUM
problem
elements
inside
the
array.
Even
though
the
running
time
of
the
N"hacking"
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
still
fast
enough
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
constraint.
Anoth
N
ven
though
the
running
time
of
the
the
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
way
N/2
stant.
It
is
rare
that
we
can
get
Accepted
the
contestant.
by
only
"hacking"
It
is
rare
a
that
complete
we
can
search
get
Accepted
algorithm.
by
Therefore,
only
we) (e.g.
a complete
will
discuss
technique
inin
detail.
way
to
apply
this
technique
isis)to
when
therun
value
of Nsecond,
tooFor
large
<isuse
40).
For
example,
while
O4
way
apply
this
technique
isnot
when
the
value
ofNN
not
too
large
N
<
the
givenalgorithm
Another
isfor
isconstraint.
when
the
value
of
Nthis
not
too
large
(e.g.
Nis <
40).
example,
while
O(2
)tois
Ntechnique
< 40).
For
example,
while
O(2
fornot
N
= 36
is
unlikely
to
one
we
can,
for(e.g.
instance,
agiven
O(2
Meet
In
The
BSET-SUM
problem
f
the
elements
inside
the
array.
Even
though
the
running
time
of
the
N/2
n
the
constraint
that
e
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
N
N/2
way
to
apply
this
technique
is
when
the
value
of
N
is
not
too
large
(e.g.
N
<a
way
to
apply
this
technique
is
when
the
value
of
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
N/2
hscuss
for
the
given
constraint.
Another
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50
apply
this
technique
is
when
the
of

is
not
too
large
(e.g.
).
For
exN/2
this
technique
in
detail.
will
not
discuss
this
technique
in
detail.
for
N
=
36
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
M
algorithm
for
N
=
36
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
<ce,
40).
For
example,
while
O(2
)
=
36Suppose
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
Middle
use
aalgorithm
O(2
)
Meet
In
The
Middle
for solving a problem like SUBSET-SUM.
While O(2
) is still exponential
to N , it is much fas
2 algorithm
N
N/2
N
n
the
constraint
that
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
N/2
N/2
geut,
O(N
X
)
Dynamic
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
)
N/2
N/2
algorithm
for
=
unlikely
to
one
can,
instance,
use
ample,
while
While
algorithm
for
isis
unlikely
to run
run
in
second,
we
can,
for
= 36
isa unlikely
run
one
second,
we
can,
for
instance,
use
aa O(2
)solution.
In The
Midd
<
For)to
example,
while
O(2
)than
Sometimes
also
look
for
other
small
constraints
that
For
example,
athan
proble
N
NSUBSET-SUM
algorithm
solving
problem
like
SUBSET-SUM.
While
O(2
)help.
still
exponential
to
,Meet
much
faster
algorithm
for
solving
a36problem
likemay
SUBSET-SUM.
While
O(2
)itfor
isis still
exponent
a 40).
O(2
Meet
InN
The
Middle
lving
aalgorithm
problem
like
SUBSET-SUM.
O(2
)Nissolve
still
exponential
to
N
,isof
itin
isN
much
faster
xponential
N
,we
itfor
isshould
much
faster
Nto
that
itin
can
is
twice
the
range
using
O(2
)N
3.3
Finding
Small
Constraints
2N/2O(2 ), and the range of N/2
N
N/2
N/2
gese
O(N
X
)
Dynamic
ue
of
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
)
N
N
N and
running
time
of
the
ond,
we
can,
for
instance,
a
O(2
)
Meet
The
Middle
N
for
use
a

Meet
In
The
Middle
algorithm
for
solving
a
problem
like
algorithm
for
solving
a
problem
like
SUBSET-SUM.
While
O(2
)
is
still
expone
algorithm
for
solving
a
problem
like
SUBSET-SUM.
While
O(2
)
is
still
exponential
to
N
,
it
is
much
faster
thN
N
a
O(2
)
Meet
In
The
Middle
is
considered
an
NP-hard
problem,
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
tha
),
the
range
oftwice
NO(2
that
canthe
solve
isusing
twice
range
of solve
N Finding
using
a O(2
)range
solution.
and
of N
that
can
is twice
the
of
N using a O(2
toofO(2
N)N
,solution.
itthat
is and
much
faster
than
range
it can
solve
isFinding
the),itrange
of range
NConstraints
a the
O(2
)it solution.
gntial
a O(2
3.3
Small
3.3
Small
Constraints
N/2
N/2
Nit
N
Nfaster
2
running
time
of
the
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
Middle
ne(2
constraint.
Another
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
exponentially
SUBSET-SUM.
While

is
still
exponential
to
,
it
is
much
than
.eWhile
O(2
)
is
still
exponential
to
N
,
is
much
faster
than
N
O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(
O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(2
)
solution.
nential
to
N
,
it
is
much
faster
than
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynam
) solution.
N/2
3.4
Finding
Special
Cases
N
N
nthere
constraint.
Another
isWhile
an NP-hard
large
Suppose
isimpossible
an
NP-hard
to
solve
problem
exponentially
with
large
(e.g.
N
N
is>a
impossible
50). time
toofsol
range
oftoN
that
itmuch
can
solve
isinside
twice
the
range
ofthough
that
using
SUM.
O(2
), problem
isand
still
exponential
N that
, there
it
is
faster
than
ample,
while
O(2
)where
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a SUBSE
ice
the
range
of
NN using
aXthe
O(2
) solution.
O(2
)Programming,
solution.
iswith
the
upper
bound
ofis
the
elements
the
array.
Even
the
running
th
3.4
Finding
Special
Cases
3.4
Finding
Special
Cases
3.4
Finding
Special
Cases
es
N solution.
N
ample,
while
O(2
)
sMeet
should
also
look
for
other
small
Sometimes
constraints
we
that
should
may
help.
also
look
For
for
example,
other
small
a
SUBSET-SUM
constraints
that
problem
may
help.
For
ex
iswe
twice
the
range
of
N
using
a
O(2
)
solution.
In TheThis
Middle
is considered
an size
NP-hard
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
th
algorithm
is is
exponential
the
of 3.4
theproblem,
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Anoth
the
most to
suitable
approach
inFinding
IOI,
and
thus
is
the
main
focus
of
this
paper.
To
solve
IOI
200
Finding Special Cases
Special 3.4
Cases
In
The
Middle
red
an
NP-hard
problem,
and
willIsland
not
isinside
be
considered
solvable
with
an
NP-hard
NNapproach.
=
100.
When
and
we
are
willnd
given
not
be
the
solvable
constraint
with
N
=
100.
When
tMeet
issuitable
much
faster
than
all
the
elements
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
bethat
solved
using
O(
This
is
the
most
suitable
approach
in
IOI,
and
thus
isproblem,
the
main
focus
of
paper.
To
solve
2008
IsN
This
isthe
the
most
suitable
approach
in
IOI,
and
thus
is
the
main
focus
of
this
pa
ting
approach
in IOI
IOI,
and
thus
is
main
focus
of
paper.
To
solve
2008
Island
way
to
apply
this
technique
is
the
value
of
isthis
not
too
large
(e.g.
NIOI
<
40).
For
example,
while
O(2
this
paper.
To
solve
2008
and
IOI
2014
Friend,
wewhen
need
to
use
this
We
must
athis
special
constraint
inIOI
the
probl
Special
Cases
2
This
isin
the
most
suitable
approach
inthis
IOI,
and
thus
main
focus
ofcan
this
N/2
This
issolve
the
most
suitable
approach
IOI,
and
thus
isthe
the
main
focus
of
this
paper.
To
solve
IOI
2008
Isla
tpaper.
is much
faster
than
ments
inside
the
array
are
small
(e.g.
allto
the
[0,
100]),
elements
this
inside
problem
can
array
be
are
solved
small
(e.g.
O(N
[0,
100]),
Xis
)the
Dynamic
problem
be
n.
Programming,
where
X
is
upper
of
the
elements
inside
array.
Even
though
the
run
and
IOI
2014
we
need
to
use
this
approach.
We
must
nd
athe
special
constraint
in
the
problem
and
IOI
2014
Friend,
we
need
to
use
approach.
We
must
nd
special
c
To
IOI
2008
Island
Friend,
we
need
to
use
this
approach.
We
must
nd
a bound
special
constraint
inusing
problem
such
algorithm
for
N
=Friend,
36
is
unlikely
run
inthe
one
second,
we
can,
for
instance,
use
athe
O(2
)this
Meet
InaThe
Midd
pecial
constraint
in
the
problem
such
Finding
Special
Cases
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
ad
hus
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
and
IOI
2014
Friend,
we
need
to
use
this
approach.
We
must
nd
a
special
N/2
and
IOI
2014
Friend,
we
need
to
use
this
approach.
We
must
nd
a
special
constraint
in
the
problem
su
s.aint
paper.
To
solve
IOI
2008
Island
n.
ming,
where
X
is
the
upper
bound
of
Programming,
the
elements
inside
where
the
X
array.
is
the
Even
upper
though
bound
the
of
the
running
elements
time
inside
of
the
the
array.
Eve
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
given
con
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
additi
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
ca
constraint
in the
problem
such
the
problem
toan
solvable
polynomial time.
WeO(2
can check
whether
an additional
algorithm
for
solving
a be
problem
likeinSUBSET-SUM.
While
) is still
exponential
to N , it is much faster tha
Weallows
can check
whether
additional
nd
thus
theinto
main
focus
of
this
paper.
Tothe
solve
IOI
2008
Island
ach.
WeisNmust
nd
asize
special
constraint
in
problem
such
that
this
constraint
allows
the size
problem
togiven
be
solvable
in polynomial
time.
We
N algorithm
that
this
constraint
the
problem
to
be
solvable
invalue
polynomial
time.
can
check
an
addition
al
constraint
the
problem
is exponential
the
ofallows
thesuch
input,
algorithm
the
algorithm
is exponential
istwice
still
fast
to
enough
for
of
input,
constraint.
the
Another
is
enough
way
to
apply
this
technique
is
the
ofofN
not
too
large
Nwhether
< still
40).fast
For
examp
can
check
whether
an
additional
O(2
), and
the
range
of
N
that
it can
solve
iswhen
the
range
Nisthe
using
aWe
O(2
) (e.g.
solution.
N
N/2
pproach.
We
must
nd
a
special
constraint
in
the
problem
such
able
in
polynomial
time.
We
can
check
whether
an
additional
eply
canthis
check
whether
an
additional
technique
isalgorithm
when
thefor
value
N
toisisapply
not too
thistolarge
technique
when
< 40).
the
For
value
example,
of N
iswhile
not too
O(2
<
N way
=of36
unlikely
run (e.g.
in oneisNsecond,
we
can,
for
instance,
use large
a)O(2(e.g.) N
Mee
Irvin
GUNAWAN
N/2 N/2
eolve
solvable
inJonathan
polynomial
time.
Weone
can
check
whether
an
additional
IOI=2008
Island
for
N
36
is
unlikely
to
run
in
algorithm
second,
we
for
can,
N
=
for
36
instance,
is
unlikely
use
to
a
run
O(2
in
one
)
Meet
second,
In
The
we
can,
Middle
for
instance,
use
algorithm
for
solving
a
problem
like
SUBSET-SUM.
While
O(2
)
is
still
exponential
to
N
,
it
is
Jonathan Irvin GUNAWANJonathan
Irvin Finding
GUNAWANSpecial Cases
GUNAWAN
3.4
N/2
N/2 N
olve
IOI
2008
Island
n
problem
suchO(2
Irvin
GUNAWAN
forthe
solving
a problem
likeNSUBSET-SUM.
algorithm
for
O(2
solving
is
a problem
still
exponential
to range
N , it of
is much
faster
O(2
than
) is
still expone
Jonathan
Irvin
GUNAWAN
), and the Jonathan
rangeWhile
of N
that
it )can
solve
is like
twiceSUBSET-SUM.
the
NWhile
using
a O(2
) solution.
N
N
n
the
problem
such
hether
an
additional
is the
approach
in), the
IOI,
and
thus
the
main
of this
paper.theTorange
solveofIOI
2008 Islan
nd theThis
range
of Nmost
thatsuitable
it can solve
isO(2
twice
andrange
the range
of Nisof
using
N that
a O(2
itfocus
can
) solution.
solve
is twice
N using
aO
hether
an IOI
additional
and
2014 Friend, we need to use this approach.
We
must
nd
a
special
constraint
in
the
problem
suc
3.4 Finding Special Cases
that this constraint allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
addition
3.4 Finding Special Cases
3.4 Finding Special Cases
This is the most suitable approach in IOI, and thus is the main focus of this paper. To solve
e most suitable approach
in 2014
IOI, and
This
thus
iswe
is
thethe
most
main
focus
approach
this paper.
in IOI,
Tomust
and
solve
thus
IOIisa2008
the
main
Island
focus of this
and IOI
Friend,
need
tosuitable
use
thisof
approach.
We
nd
special
constraint
in th
014 Friend,
we
need
to
use
this
approach.
and
IOI
2014
We
must
Friend,
nd
we
a
need
special
to
constraint
use
this
approach.
in
the
problem
We
must
such
nd
a
special
this constraint allows the problem to be solvable in polynomial time. We can check wheth
Jonathan Irvin that
GUNAWAN
constraint allows the problem to be that
solvable
this in
constraint
polynomial
allows
time.theWe
problem
can check
to bewhether
solvableaninadditional
polynomial time. We

Irvin GUNAWAN

Jonathan Irvin GUNAWAN


Fig. 4. Comparison of O(2N) and O(2N/2) SUBSET-SUM algorithm running time for various
Jonathan
GUNAWAN
input sizes. This experiment
is runIrvin
100 times
for each value of N on a MacBook Pro (Retina,
13-inch, Early 2015).

em. The most common approximation algorithm I found in textbooks


is theApproximation
3.1
OVER problem, which means that the algorithm will not choose more than twice
In real life, when
we cannot
theinoptimal
solution, we can try to nd the solution th
ptimal solution. However, approximation
problems
rarelynd
occur
competitive
2
2
Identifying
Identifying
Intractability
Intractability
2
Identifying
of
of
a
a
Problem
Problem
Intractability
through
through
Reduction
Reduction
ofa(where
Pro
solution.
More
specically,
we
try
to
nd
a
solution
that is not larger
than
J.I. Gunawan
e of the reason is92because to create this kind of problem,
the judges have to
Identifying Intractability
of
a
Problem
through
Reduction
solution
for ais minimisation
problem. The
most common approximation algorithm I f
r to
that
contestants
solution
indeed
We
Weverify
would
would
like
likethe
to
to know
know that
that the
the
problem
problem
that
thatWe
we
we-approximation.
are
would
are attempting
attempting
like to know
isisHowever,
unlikely
unlikely
that the
to
toproblem
have
have an
anthat
immediate
immediate
we are solution.
solution.
attempting
The
The
is
3.4.
Finding
Special
Cases
2-approximation
MIN-VERTEX-COVER
problem,
which
means thatsolution.
the algorithm
will no
impossible
(orknow
takes
a isis
long
time).
is not
really
suitable
for
would
to
that
the
problem
thatthis
we approach
aremost
attempting
is
unlikely
have
immediate
The
most
mostlike
common
common
way
way
to
to apply
apply
aaSince
well-known
well-known
technique
technique
common
called
called
way
reduction.
reduction.
is totoapply
Suppose
Suppose
aanwell-known
we
we know
know
technique
that
that problem
problem
calledXXredu
isis
number of
vertices than
the
optimal solution.
However,
approximation
problems ra
ot
discuss this
in we
detail.
t common
way
is
athe
well-known
technique
called
reduction.
we
know
that
problem
X
impossible
impossible
to
toapproach
solve,
solve,
and
and
we
also
also know
know that
that
we
weimpossible
can
can solve
solve problem
problem
to
solve,XXand
by
bySuppose
using
we
using
also
problem
problem
know
that
YY as
as
we
aa black-box
black-box
can
solve11.problem
. IfIfiswe
we can
can
Xb
22to apply
Identifying
Identifying
Intractability
Intractability
of
of
a
a
Problem
Problem
through
through
Re
Re
programming
(especially
IOI).
One
of
the
reason
isfocus
because
to paper.
create
this
kind
of pro
1 To
This
is
the
most
suitable
approach
in
IOI,
and
thus
is
the
main
of
this
ossible
solve, and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
black-box
.
If
we
can
solve
solvetoproblem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
X
solve
as
as
well.
well.
problem
Therefore,
Therefore,
Y,
then
problem
problem
we
can
Y
Y
solve
is
is
also
also
problem
impossible
impossible
X
as
to
well.
to
solve.
solve.
Therefore,
pr
N/2
omparison of O(2N
) and
O(2
)toSUBSET-SUM
algorithm
running
time
for
various
input
sizes.
This
know
the
optimal
solution
in order
to
verify
that
the
contestants
solution
isimmediate
indeed We
We
would
would
like
likeproblem
to
know
know
that
the
the
problem
problem
that
that
we
we
are
are
attempting
attempting
is
is
unlikely
unlikely
to
to
have
have
an
an
immediate
IOI
2008
Island
and
IOIwell.
2014
Friend,
we
need
to
use
this
approach.
We
must
find
e problem Y, 3.2
thensolve
wePruning
can
solve
Xthat
as
Therefore,
problem
Y
is
also
impossible
to
solve.
NN
N/2
N/2
Figure
4:
Comparison
ofof
)Pro
) )NSUBSET-SUM
running
time
for
variou
Figure
4:of
Comparison
O(2
)and
and
SUBSET-SUM
algorithm
running
time
for
vario
N/2
NO(2
is run 100 times for
each
value
N4:on
atoMacBook
(Retina,
13-inch,
Early
2015)
generating
the
optimal
solution
is
impossible
(or
takes
athe
long
time).
Since
this
approac
Figure
4:O(2
Comparison
of
O(2
)N/2
and
O(2
)algorithm
SUBSET-SUM
algorithm
runnin
Figure
Comparison
O(2
)O(2
and
O(2
)problems
SUBSET-SUM
algorithm
running
time
for
most
common
common
way
way
isis
to
apply
apply
aaof
well-known
well-known
technique
technique
called
called
reduction.
reduction.
Suppose
Suppose
we
we
know
know
that
tha
special
constraint
in
the
problem
such
that
this
constraint
allows
problem
to
be
We
We are
are using
usingamost
NP-hard
NP-hard
problems
problems
for
for
illustration.
illustration.
We
Recall
Recall
are
that
that
using
NP-hard
NP-hard
NP-hard
problems
problems
have
have
for
illustration.
yet
yet
to
to
be
be
solved
solved
Recall
in
in
polynomial
that
polynomial
NP-har
N
N/2
Figure
4:
Comparison
of
O(2
)
and
O(2
)
SUBSET-SUM
algorithm
running
time
foE
experiment
is
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
13-inch,
Early
20
algorithm
running
time
for
various
input
sizes.
This
experiment
is
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
13-inch,
Early
2
mpetitive
programming
problems.
In
ACM
International
Collegiate
Programming
competitive
programming,
I
will
not
discuss
this
approach
in
detail.
SUBSET-SUM
algorithm
running
time
for
various
input
sizes.
This
experiment
is
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
experiment
is
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
13-inch,
N
N/2
solvable
in
polynomial
time.
We
can
check
whether
an
additional
constraint
causes
a
impossible
impossible
to
to
solve,
solve,
and
and
we
we
also
also
know
know
that
that
we
we
can
can
solve
solve
problem
problem
X
X
by
by
using
using
problem
problem
Y
Y
as
as
a
a
black-b
black-b
Wetime
are using
NP-hard
forMIN-VERTEX-COVER
illustration.
Recall
that
NP-hard
problems
have
yet
to befor
solved
inaapolynomial
time
for
for4:more
more
than
thanproblems
44 decades.
decades.
time
for is
more
isfor
aa graph
graph
than
problem
4problem
decades.
that
that
MIN-VERTEX-COVER
involves
involves
nding
nding
minimum
minimum
is sizes.
a 13-inch,
graph
subset
subset
pro
Figure
Comparison
of O(2
)MIN-VERTEX-COVER
and O(2
)100
SUBSET-SUM
algorithm
running
time
various
input
This
experiment
is
run
times
each
value
of
N
on
a
MacBook
Pro
(Retina,
E
ok
Pro
(Retina,
13-inch,
Early
2015)
0, on
problem
I (Robots
on
Ice)
required
the
contestant
to count
number
of
N
MacBook
Pro
(Retina,
13-inch,
Early
2015)
problem
to
bein
solvable
in
polynomial
time
using
the
reduction
proof
of
the
original
N
N/2
solve
solve
problem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
Xthe
as
as
well.
well.
Therefore,
Therefore,
problem
YY2015)
is(withis
also
also
impossible
impossible
auses
aa problem
torun
be100
solvable
polynomial
time
using
the
reduction
proof
of
the
original
problem
for
than
decades.
MIN-VERTEX-COVER
is
aits
graph
problem
involves
nding
avarious
minimum
subset
of
ofmore
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
atO(2
least
least
one
one
of
of
of
nodes
its
endpoint
endpoint
such
that
isisPro
in
for
inthat
the
the
every
subset.
subset.
edge,
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
atproblem
least
one
ofprobits
endpoint
isisto
ato
in
a
experiment
is4N
times
for
each
value
of
N
on
a
MacBook
(Retina,
13-inch,
Early
Figure
4:
Comparison
of
O(2
)
and
)
SUBSET-SUM
algorithm
running
time
for
input
sizes.
This
N
N/2
N/2
ts (ACMofICPC
World
Finals
2010
problem
statement
n.d.),
which
isSUBSET-SUM
known
to
Figure
of
O(2
)bebe
and
O(2
)additional
algorithm
running
time
various
mparison
O(2for
)of
and
O(2
)Comparison
SUBSET-SUM
algorithm
running
time
forathe
various
input
sizes.
This
lem
(without
the
additional
constraint),
and
whether
proof
still
holds
given
the
constraint
causes
acauses
problem
to
in
time
using
the
reduction
proof
of
the
orig
constraint
causes
aproof
problem
to
solvable
inpolynomial
polynomial
time
using
the
reduction
proof
of
the
or
3.2
Pruning
tional
constraint),
and
check
the
still
holds
the
constraint
to
theone
problem.
odes
such
that
every
edge,
at
least
one
of
endpoint
ischeck
in
the
subset.
MAX-INDEPENDENT-SET
isfor
aproof
graph
graph
problem
problem
of
nding
nding
a4:
awhether
maximum
maximum
subset
subset
of
of
graph
nodes
nodes
problem
such
such
that
that
of
nding
for
for
every
every
maximum
edge,
edge,
at
at
most
most
subset
one
of
of
of
nodes
its
its
endpoint
endpoint
such
that
isis for
in
in
experiment
is run
100
times
for
each
value
of
N
on
asolvable
MacBook
Pro
(Retina,
13-inch,
Early
2015)
constraint
causes
agiven
problem
to
bein
solvable
in
polynomial
time
using
the
reductio
constraint
aits
problem
to
be
solvable
polynomial
time
using
the
reduction
of
ding
all
possible
paths
is
impossible,
the
solution
for
this
problem
is
to
prune
experiment
is
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
13-inch,
Early
201
additional
constraint
to
the
problem.
run
100
times
for
each
value
of
N
on
a
MacBook
Pro
(Retina,
13-inch,
Early
2015)
constraint
causes
a
problem
to
be
solvable
in
polynomial
time
using
the
reduction
proof
of
out
additional
constraint),
and
check
whether
the
proof
still
holds
given
the
additional
constra
ing
the
reduction
proof
of
the
original
problem
(without
the
additional
constraint),
and
check
whether
the
proof
still
holds
given
the
additional
constr
We
We
are
are
using
using
NP-hard
NP-hard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
that
NP-hard
NP-hard
problems
problems
have
have
yet
yet
to
to
be
be
solved
solve
h the
problem
of using
nding
a we
maximum
subset
of
nodes
that
for
everyand
atthe
most
one
ofholds
its
endpoint
in show
the subset.
subset.
Suppose
Suppose
we already
already
know
know
that
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
thesuch
subset.
Suppose
iswe
isedge,
aaalready
NP-hard
NP-hard
know
problem.
problem.
that
MIN-VERTEX-COVER
Therefore,
Therefore,
we
weisInternationa
can
can
show
lynomial
time
the
reduction
proof
of
the
problem
(without
the
additional
constraint),
check
whether
the
proof
stillACM
holds
given
theis
out
the
additional
constraint),
and
check
whether
proof
still
given
the
additional
This
approach
isinoriginal
useful
some
competitive
programming
In
causes
apaths
problem
to be
solvable
polynomial
time
using
the
proofproblems.
of the
original
problem
(withICPC
World
Finals
2010
Solutions
n.d.).
at
toconstraint
ndgiven
all possible
(ACM
We
will
give
we
example
ofin
aproblem
special
case
in
a reduction
NP-hard
Suppose
we
out
the
additional
constraint),
andis
check
whether
the problem.
proof
still
holds
given
the
additional
holds
the
additional
to
the
time
time
for
more
more
than
than
4one
4also
decades.
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
iswe
is If
aaaaproblem.
graph
graph
problem
that
that
involves
involves
nding
nding
aaaam
m
give
we
onestill
example
offor
aconstraint
special
case
in
aaproblem.
NP-hard
problem.
Suppose
have
aisproblem
function
withwe
the
subset.
Suppose
we
already
know
that
MIN-VERTEX-COVER
areducing
NP-hard
Therefore,
can
show
that
that
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
is
is
also
a
NP-hard
NP-hard
that
MAX-INDEPENDENT-SET
problem
by
by
reducing
MIN-VERTEX-COVER
MIN-VERTEX-COVER
also
a
NP-hard
problem
problem
problem
by
into
into
reduc
er
the
proof
holds
given
the
additional
constraint
to
the
problem.
Contest
(ICPC)
World
Finals
2010,
problem
Iand
(Robots
onofIce)
required
the
contestant
out
the
additional
constraint),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
to
the
problem.
constraint
causes
a
problem
to
be
solvable
in
polynomial
time
using
the
reduction
proof
the
original
problem
(withossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
have
a
function
with
the
following
formula
We
give
one
example
of
case
inthe
NP-hard
problem.
Suppose
we
have
a
We
will
give
we
one
example
ofafor
aspecial
special
case
in
aspecial
NP-hard
problem.
Suppose
have
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
ofspecial
its
endpoint
endpoint
isThis
inNP-hard
the
the
subset.
subset.
MAX-INDEPEND
MAX-INDEPEND
N
N/2
rmula
MAX-INDEPENDENT-SET
iswill
also
awill
NP-hard
problem
by
reducing
aits
MIN-VERTEX-COVER
problem
into
awe
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
problem.
problem.
MAX-INDEPENDENT-SET
problem.
constraint
causes
awe
problem
to
be
solvable
inexample
polynomial
time
using
the
reduction
proof
of
the
origi
ses
a) problem
to
beof
inHamiltonian
polynomial
time
using
the
reduction
proof
of
original
problem
We
will
give
we
one
of
aasizes.
case
in
a (withNP-hard
problem.
Su
We
give
we
one
example
of
aof
case
inis
ain
problem.
Suppose
we
(2
and
O(2suitable
)ofsolvable
SUBSET-SUM
algorithm
running
time
various
input
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
out
thevery
additional
constraint),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
to
the
problem.
it
is
not
for
IOI.
Usually,
IOIgive
problems
require
deep
analysis
from
We
will
we
one
example
of
a
special
case
in
a
NP-hard
problem.
Suppose
we
following
formula
ard
problem.
Suppose
we
have
a
function
with
the
following
formula
graph
graph
problem
problem
of
of
nding
nding
a
a
maximum
maximum
subset
subset
of
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
most
most
one
one
of
of
its
its
X-INDEPENDENT-SET
problem.
out
the
additional
constraint),
and
check
whether
proof
still
holds
given
the additional
constrai
onal
constraint),
and
check
the
proof
stilla formula
holds
given
the
additional
constraint
toiswe
the
problem.
case
ineach
a NP-hard
problem.
Suppose
we
have
function
the
following
following
formula

s forget
value
of
Nonly
on
awhether
MacBook
Pro
(Retina,
13-inch,
Early
2015)
be a NP-hard
problem.
While
nding
allthe
possible
paths
impossible,
the solution
for
We
will
give
we
one"hacking"
example
a special
case
in
a with
NP-hard
problem.
have
a function
with the
can
Accepted
by
aofcomplete
search
algorithm.
Therefore,
weSuppose
following
formula
the
the
subset.
subset.
Suppose
Suppose
we
we already
already
know
know
that
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
isis aa NP-hard
NP-hard problem.
problem. Therefore
Therefor
1,
n
=
1

n
=
2

We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
We
will
rst
prove
the
following
two
lemmas.
N following
N/2

ICPC
World
Finals
2
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
f
(n)
=
formula
We
will
give
we
one
example
of
a
special
case
in
a
NP-hard
problem.
Suppose
we
have
a
function
with
the
) and O(2
) SUBSET-SUM
algorithm running time
foraavarious
sizes. by
This
etail.
1,1,input
nn=
1MIN-VERTEX-COVER
n
=MIN-VERTEX-COVER
1nthe
that
MAX-INDEPENDENT-SET
isproblem.
is also
also
NP-hard
NP-hard
problem
problem
by
reducing
reducing
aawith

We
willone
rstexample
prove that
the
We
will
give
we+
one
example
of
a2impossible
special
case
a NP-hard
problem.
Suppose
we
=2have
1then
naw
=
1,invisit
=n=1=22points,
nn=
f two
(n
lemmas.
1)
f (n
2),
n
>(n)
ve we
of following
aMAX-INDEPENDENT-SET
special
case
in
awe
NP-hard
Suppose
we
have
a1,
function
f
(n)
=
f
=
some
point
know
that
it
is
to
the
rest
of
the
unvisited
following
formula
ortoLemma
each
value
of
on
MacBook
Pro the
(Retina,
13-inch,
Early
2015)
be solvable
polynomial
time
using
reduction
proof
problem
(withf1,1)
(n)
=
f (n)
=

Lemma
1.
1.
Lemma
1.of Ifthe
Ifin
If N
SS

VVa is
is an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of graph
graph
S
G(V,
G(V,

VE),
E),
then
an
then
VV

2),
SS2),
isis n
aanVERTEX-COVER
VERTEX-COVER
of
of the
theE
n = of
1 graph
n = 2G(V,
MAX-INDEPENDENT-SET
problem.
problem.
foriginal

1)
++
fINDEPENDENT-SET
>
f(n
(n
is
f(n
(n
2(n
n following
= 1 nbacktrack
=formula
2
mula n = 1 n = 2MAX-INDEPENDENT-SET
fE),
(n)
=not
fa
(n

1)IOI.
+>2fto
22),IOI
nthe
>2
fto
(n

1)
+
fVERTEX-COVER
(n
2),
nknow
>
1,
n
=
1

n
=
2
immediately.
However,
it
is
very
suitable
for
Usually,
problems
r
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
t),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
the
problem.
mma
1.
If
S

V
is
an
INDEPENDENT-SET
of
graph
G(V,
then
V

S
is
of
N/2
graph
graph
G(V,
G(V,
E)
E)
graph
G(V,
E)

n=1
3.3
Finding
Small
Constraints
)),
and
SUBSET-SUM
algorithm
running
time for various
f (n This
1) + f (n 2), n > 2
f (n) =
n+O(2
>
2(n )2),

input sizes.

1)
f
n
>
2

We
consider
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
consider
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
We
consider
the
sequence
,
and
we
define

to
be
the
first

the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
1,
n
=
1

n
=
2
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
n=1
n=1
ffollowing
(n

1)
+
f=
(n
original
2),F n=1
n {f
>
2 we
hbe
G(V,
E) in
We
consider
the
sequence
=
(n)}
, and we
dene
F=(N
) to
rs
consider
the
sequence
{f
(n)}
, and
dene
F (N
)
tonbe
the
rstbeNthe
term
n=1
We
will
willWe
rst
rst
prove
prove
the
the
following
two
lemmas.
lemmas.
each
value
ofus
Nassume
on aWe
MacBook
Pro
13-inch,
Early
solvable
polynomial
time
reduction
proof
of
the
(with1,
n
=
2A,
fS
(n)
=
problem
1,
n two
=F
1of

n2015)
=
2Therefore,
Proof.
Proof.
Proof.
Let
Let
us
assume
that
that
Vusing
VB

Sthe
is(Retina,
is
not
not
VERTEX-COVER.
VERTEX-COVER.
Let
us
assume
Therefore,
that
Vthere
there
dene
SReduction
are
is
are
two
a 1vertices
vertices
VERTEX-COVER.
A,
B
B

/
/that
VN
V

The
SS s
We
consider
the
sequence
F
=
{f
(n)}
, into
and
we
Ftwo
(N
)A
be
the
rst
term
whether
we
can
create
partition
of
F
)partition
multisets
A
and
B
such
the
ntifying
ntifying
Intractability
Intractability
of
of
a
a
Problem
Problem
through
through
Reduction
N
)to
tothe
be
the
rst
Nto
terms
of
F
.
We
want
toaathis
know
with
large
N
that
whether
isof
impossible
can
create
to
solve
a(n
partition
exponentially
F(N
(N
(e.g.
)into
into
Ntwo
two
>
50).
disjoint
multisets
and
B
such
that
the
case
terms
.we
We
want
to
know
whether
we
can
create
adisjoint
partition
ofnot
to
into
two
will
not
discuss
technique
in
detail.
n=1
al
sum
of
all
elements
in
fpartition
(n)
=
ample
of
a
special
in
a
NP-hard
problem.
Suppose
we
have
a
function
with
the
f
(n)
=
f

1)
+
f
(n

2),
n
>
2
dblem
we
dene
F
(N
)
be
the
rst
N
terms
of
F
.
We
want
to
know
whether
we
can
create
a
of
F
(N
)
into
two
disjoint
multisets
A
and
B
whether
we
can
create
a
of
F
(N
)
two
disjoint
multisets
A
and
B
such
tha

and
check
whether
the
proof
still
holds
given
the
additional
to
the
problem.
We
consider
thedisjoint
sequence
{f
,create
and
we
dene
(N
)F
to
be
rst
N
terms
of
Fthe
.BWe
want
know
n=1
fin
(n

1)
+the
f (n

2),
nAs
>
2Since
of.
Let
us
that
Vconnecting

is=
not
aV+
VERTEX-COVER.
Therefore,
there
are
vertices
A,

/are
V a
fF
(n

1)
fiscan
(n
2),
nA,
>
and
and
there
there
isconstraints
is an
an
edge
edge
connecting
A
A(n)}
and
and
B.
B.
Since
Since
and
there
B
B2
/constraint

/is
VVF
an

edge
S,
S,
we
we
connecting
have
have
A,
A,
B
Btwo
A

and
S.
S.
As
B.
A
A
and
and
B
A,
B
B
are
/a
connected
connected
V
S, we
whether
aA,
partition
of
(N
)problem
into
two
disjoint
multisets
A
and
BSto
such
th
Vwe
and

such
that
the
sum
of
all
elements
in
is
equal
toV
sum
inthat
Amultisets
is
equal
to
the
sum
of
all
elements
in
B
multisets
A assume
and
B
such
the
sum
of
all
elements
small
in
that
A
isS
may
equal
help.
to
the
For
sum
example,
ofsum
all
aof
elements
SUBSET-SUM
B
Lemma
Lemma
1.
1.
If
If
SS

is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V

S
S
is
is
VERTEX-C
VERTEXo other
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
in
A
is
equal
to
the
sum
of
all
elements
in
B
in
A
is
equal
to
the
all
elements
in
B

whether
can
create
a partition
of
F
(N
),the
into
two
disjoint
multisets
A
and
Bnot
such
that
the
ofwant
all
elements
We
the
sequence
F
=
{f
(n)}
and
we
dene
Fwe
(N
)This
to
be
the
rst
N
terms
of
F
.sum
We
toSSknow
ke
ke
to
to will
know
know
that
that
the
the
problem
problem
that
that
we
we
are
are
attempting
attempting
is
unlikely
unlikely
to
to
have
have
an
an
immediate
immediate
solution.
solution.
The
The
there
isconsider
edge
connecting
A
and
B.
Since
A,
Bsum

/{f
Vis

S,
have
B

S.
As
and
B
are
connected
n=1
by
by
an
an
edge,
edge,
we
we
note
note
that
that
an
edge,
note
that
S
S
isis
not
an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
This
is
is
athat
aof
S
contradiction.
contradiction.
isF
INDEPENDENT-SET.
Therefore
Therefore
V

of
all
elements
in
not
.sequence
eand
solvable
inwe
polynomial
time
using
the
reduction
proof
of
the
original
problem
(within
A
iswe
equal
to
of
all
elements
inA,
B
not
be
solvable
with
N
=the
100.
When
we
are
given
the
constraint

graph
graph
G(V,
G(V,
E)
E)
ks
like
a an
classic
PARTITION
problem.
PARTITION
problem
is3.3
by
reduction
from
SUBSETWe
consider
Fby
=
(n)}
,aNP-hard
and
we
dene
(N
)Aan
to
beConstraints
the
rst
N Vterms
ofisisThi
Faa.
he
sequence
F
=
{f
(n)}
,
and
dene
F
(N
)
to
be
the
rst
N
terms
F
.
We
want
to
know
Finding
Small

n=1
n=1
mple
of
a
special
case
in
a
NP-hard
problem.
Suppose
we
have
function
with
the
in
A
is
equal
to
the
sum
of
all
elements
in
B
whether
we
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
2
on
on
way
way
is
to
to
apply
apply
a
a
well-known
well-known
technique
technique
called
called
reduction.
reduction.
Suppose
Suppose
we
we
know
know
that
that
problem
problem
X
X
is
is
n
edge,
we
note
that
S
is
not
an
INDEPENDENT-SET.
This
is
a
contradiction.
Therefore
V

S
is
a
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
VERTEX-COVER.
VERTEX-COVER.
ndVERTEX-COVER.
check
the
proof
still
holds
given
the
additional
constraint
to) two
the
problem.
This
like
classic
PARTITION
PARTITION
problem
isin
bybyreduct
are
small
100]),
this
This
problem
looks
like
can
aThis
be
solved
using
O(N
X
Dynamic
PARTITION
problem
isNP-hard
NP-hard
reduc
1,value
na=
1classic
=PARTITION
2like
efore,
for whether
a partition
large[0,
of(N
N
itlooks
is
unlikely
to
be
toofA
nd
an
algorithm
that
nds
B
ansuch
whether
can
create
a
partition
(N
)problem.
into
disjoint
multisets
A problem
and
B
that
the
su
an
create
a(e.g.
of
F
), we
into
two
disjoint
multisets
Bproblem.
such
that
the PARTITION
sum
ofA
all1and
elements
looks
aFand
classic
PARTITION
problem.
is by
NP
This
looks
like
an able
classic
PARTITION
problem.
isproblem
NP-hard
1PARTITION
in
Af (n)
isand
equal
to
the
sum
ofTherefore,
all
elements
in
B
=
Proof.
Proof.
Let
Let
us
us
assume
assume
that
that
VVlarge

Svalue
Svalue
isisby
not
not
aN
aNVERTEX-COVER.
VERTEX-COVER.
Therefore,
Therefore,
there
are
are
two
two
vertices
vertices
A
ooN
solve,
solve,
and
we
we
also
also
know
know
that
that
we
we
can
can
solve
solve
problem
problem
XX
by
using
using
problem
problem
YY
as
as
ato
a black-box
black-box
..nd
Ifnd
Ifthere
we
we
can
can
Suppose
there
is
an
NP-hard
problem
with
large
N
that
is
impossible
to
solve
expo
reduction
from
SUBSET-SUM.
Therefore,
for
a
large
value
of
,
it
is
unlikely
to
be
TEX-COVER.
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
SUM.
for
a
large
of
,
it
is
unlikely
to
be
able
to
an
algorithm
that
n
problem
is
NP-hard
by
reduction
from
SUBSETer
bound
of
the
elements
SUM.
inside
Therefore,
the
array.
for
Even
a
though
the
of
running
,
it
is
time
unlikely
of
the
be
able
to
an
algorithm
that

y.
However,
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
in
A
is
equal
to
the
sum
of
all
elements
in
B
toLemma
the
sum
of
all
elements
in
B
em.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSETSUM.
Therefore,
for
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
at
SUM.
Therefore,
for
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
f
(n

1)
+
f
(n

2),
n
>
2
Lemma
2.
2.
Lemma
2.
If
If
S
S

V
V
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
of
graph
graph
G(V,
G(V,
If
S
E),
E),

then
V
then
is
V
a
V
VERTEX-COVER

S
S
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
graph
G(V,
of
E),
of
the
the
the
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSETand
and
there
there
is
an
an
edge
connecting
connecting
Asequence
and
and
B.
B.
Since
Since
A,
A,
B
B

/
/away.
Vconstraints
Vvery

S,
S,
we
we
have
have
A,
A,
B
Bthe

S.
S.
As
Asalgorithm
A
Athat
and
and
B
B
ancan
m
m
Y,
then
we
we
can
solve
solve
problem
problem
XXedge
as
as
well.
well.
Therefore,
Therefore,
problem
problem
isisefficient
also
also
impossible
impossible
to
to
solve.
able
find
an
algorithm
that
finds
we
and
for
in
an
However,
this
sequence
Sometimes
we
should
also
look
other
that
may
help.
For
example,
le
ofthe
athen
special
case
into
aecient
NP-hard
problem.
Suppose
have
aYY
function
with
the
SUM.
Therefore,
for
aA
value
of
N
,small
it
is
tosolve.
be
able
nd
an
ecient
way.
However,
this
sequence
isin
dened
in
way,
into
sense
that
is
ble
to
nd
algorithm
that
nds
A
and
B
in
an
way.
However,
this
is
dened
in
aunlikely
very
special
way,
in
the
ofY,
input,
the
algorithm
isis
still
fast
enough
for
the
given
Another
F
ned
recurrence.
we
should
inspect
the
formula
more
unlikely
be
able
tofor
nd
an
algorithm
that
nds
Alarge
and
Bconstraint.
an
ecient
way.
However,
this
sequence
is
dened
in
a very
special
way,
inFan
the
ecient
However,
this
sequence
is
dened
inalgorithm
aspecial
very
special
way,
insense
the
sense
th

mma
2.
Ifto
Slooks

V,Therefore,
is
aan
VERTEX-COVER
of
graph
G(V,
E),
then
Vproblem

S
isclosely.
an
INDEPENDENT-SET
of
the
1,E)
n)way.
=
1be

nNP-hard
=
2recurrence
graph
graph
G(V,
G(V,
E)
graph
G(V,
E)
SUM.
Therefore,
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
that
nds
A
and
B
in
This
like
a
classic
PARTITION
problem.
PARTITION
is
NP-hard
by
reduction
from
SUBSETN
F
=
{f
(n)}
and
we
dene
F
(N
to
the
rst
N
terms
of
F
.
We
want
to
know
by
by
an
edge,
edge,
we
we
note
note
that
that
S
S
is
is
not
not
an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
This
This
is
is
a
a
contradiction.
contradiction.
Therefo
Therefo
is
defined
in
a
very
special
way,
in
the
sense
that
is
defined
using
the
aforementioned
is
considered
an
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
n=1
ecient
way.
However,
this
sequence
is dened
in
a recurrence
very
special
way,
inmore
the
th
aforementioned
recurrence.
Therefore,
should
inspect
the
formula
closely.
way,
the
that
F
issense
dened
using
the
en
the
value
ofPARTITION
Nsense
isway,
not
aforementioned
too
large
(e.g.
recurrence.
<
40).
Therefore,
For
example,
we
should
while
O(2
inspect
)inspect
the
recurrence
more
closely.
fin
(n)
= in special
This
looks
like
aN
classic
PARTITION
problem.
PARTITION
problem
isformula
NP-hard
bysense
reductio
secial
like
aa classic
problem.
PARTITION
problem
iswe
NP-hard
by
reduction
from
SUBSETed
very
in
the
that
F
ismultiples
dened
using
the
aforementioned
recurrence.
Therefore,
we
should
inspect
recurrence
aforementioned
recurrence.
Therefore,
we
should
the
recurrence
more
hsing
G(V,
E)
ecient
way.
However,
this
sequence
dened
a of
very
special
way,
in
sense
that
F
isthe
dened
the
Any
consecutive
subsequence
of
Finstance,
with
length
three
can
be
partitioned
into
two
multisets
SUM.
Therefore,
afclosely.
large
value
of
N
it
is
unlikely
to
be
able
to
nd
anthe
algorithm
that
nds
Aformula
andusing
informu
ancc
fproblems
(n

1)for
+
(n

2),
nRecall
>
2is,should
recurrence.
Therefore,
we
inspect
the
recurrence
formula
more
closely.
N/2
artition
of
Fformula
(N
) into
two
disjoint
multisets
Athat
and
Bin
such
that
the
sum
of
all
elements
VERTEX-COVER.
VERTEX-COVER.
sing
NP-hard
NP-hard
problems
for
for
illustration.
illustration.
Recall
that
NP-hard
NP-hard
problems
problems
have
have
yet
yet
to
to
be
be
solved
solved
in
in
polynomial
polynomial
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
beB solved
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
recurrence
more
o
run
in
one
second,
we
can,
for
use
a
O(2
)
Meet
In
The
Middle

Proof.
Proof.
Proof.
The
The
proof
proof
is
is
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
The
proof
Let
Let
us
us
is
assume
assume
actually
that
that
similar
V
V

to
S
S
is
the
is
not
not
previous
a
a
INDEPENDENT-SET.
INDEPENDENT-SET.
lemma.
Let
us
assu
SUM.
for
a be
large
value
of Nan, italgorithm
isFF
unlikely
to nds
bemultiples
able
to nd
anan
algorithm
that nd
ore,aforementioned
for a large
value
of
Nformula
, Therefore,
it is
unlikely
to
able
to nd
that
A and
Bthree
in
uld
inspect
the
recurrence
more
closely.
Any
consecutive
subsequence
of
with
length
of
can
partitioned
Lemma
3.sequence
Any
subsequence
of
with
length
multiples
of
canbebeEven
partitione
Lemma
3.
recurrence.
Therefore,
we
inspect
the
recurrence
formula
closely.
m.
ecient
way.
However,
this
isisisnwhere
dened
special
way,
in
the
sense
that
Fthree
isof
dened
using
the
N/2
fe SUBSET-SUM.
all
elements
in
B
than
than
44proof
decades.
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
aashould
graph
graph
problem
problem
that
that
involves
involves
nding
nding
aaFmore
minimum
minimum
subset
subset

Programming,
X
is
the
upper
bound
of
the
elements
inside
the
array.
thoug
Any
consecutive
subsequence
of
with
length
multiples
of
three
c
1,
n
=
1consecutive

=
2Therefore,
Lemma
3.
Any
consecutive
subsequence
ofconnecting
F
with
length
multiples
three
can
be
part
Lemma
3.
ere
While
O(2
) SS
isthe
still
exponential
toin
Nathere
,very
itin
is
much
faster
than
of.
The
is
actually
similar
to
previous
lemma.
Let
us
assume
that
V

S
is
not
a
INDEPENDENT-SET.
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
to
know
Lemma
3.
Any
consecutive
subsequence
of

with
length
multiples
of
three
can
be
Therefore,
Therefore,
there
there
are
are
two
two
vertices
vertices
A,
A,
B
B

V
V

S
S
and
and
there
there
is
is
an
an
are
edge
edge
two
connecting
vertices
A,
A
A
B
and
and

V
B.
B.

S
Since
Since
and
A,
A,
there
B
B

is
V
Van

S,
S,
ecient
way.
However,
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
Fedg
is
n=1
However,
this
sequence
is
dened
in
a
very
special
way,
the
sense
that
F
is
dened
using
Lemma
Lemma
2.
2.
If
If

V
V
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V

S
S
is
is
an
an
INDEPENDEN
INDEPENDEN
f
(n)
=
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
par
Lemma
3.
of
equal
sum.
ltiples
of
three
can
be
partitioned
into
two
multisets
of
equal
sum.
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
closely.
Ninto
ch
h
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
is
is
in
in
the
subset.
subset.
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
is
is
a
a
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
with
length
multiples
of
three
can
be
partitioned
two
multisets
of
equal
sum.
of
equal
sum.

t any
can
solve
is)(n
twice
the
of
N
using
O(2
)with
solution.
fA,

1)
+
frange
(n
2),
n
>
2AaSlength
into
two
multisets
of
equal
refore,
there
are
two
vertices
A,
B

and
there
issum.
an
edge
connecting
Ais
and
B.
Sinceby
A,F
Binto
V
This
S,
tion
ofhave
F (NA,
into
two
disjoint
multisets
and
such
that
the
sum
ofwhich
allclosely.
elements
we
we
have
B
B
/
/partitioned
S.
S.
As
As
A
A
and
and
B
are
are
connected
connected
we
by
by
have
an
an
edge,
edge,
A,formula
B
we

/we
S.
note
note
As
that
A
that
and
SSwe
B
iscan
not
not
are
adenote
connected
a partitioned
VERTEX-COVER.
VERTEX-COVER.
by
an
edge,
This
we isnote
is aa
Any
consecutive
subsequence
of
FB
length
multiples
of
three
be
two
multisets
Lemma
3.
consecutive
subsequence
of
F
with
multiples
of
three,
will
=
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
closely.
ed
recurrence.
Therefore,
we
should
inspect
the
recurrence
more
graph
graph
G(V,
G(V,
E)
E)
of
equal
sum.
cem
PARTITION
PARTITION
problem
istechnique
NP-hard
reduction
from
SUBSETm
of
ofA,
nding
nding
aB
aproblem.
maximum
maximum
subset
subset
of
of
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
atF
most
most
one
one
of
ofisan
its
its
endpoint
endpoint
is
isthree,
in
inThiswhich
way
tois
apply
this
isby
when
the
value
of
NVERTEX-COVER.
not
too large
(e.g.
N
<
40).
F
note
Pick
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
we
wiw
Proof.
Pick
any
consecutive
subsequence
of
with
length
multiples
of
which
we
Proof.
ave
B

/
S.
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
is
a
l
elements
in
contradiction.
contradiction.
Therefore
Therefore
V
V

S
S
is
an
an
INDEPENDENT-SET.
INDEPENDENT-SET.
contradiction.
Therefore
V

S
is
INDEPENDENT-SET.

of
equal
sum.
+{f1),
f (a + ,2),
...f
(b)}
for
some
a
< Pick
b.
We
can
Fof
into
Any
consecutive
subsequence
ofsubsequence
Fpartition
with
length
multiples
of
three
can
into
two multisets
Lemma
3.and
Pick
any
consecutive
subsequence
ofbeof
Fpartitioned
with
length
multiples
of thr
Proof.
Proof.
any
consecutive
subsequence
of
F
with
length
multiples
ofwe
three,
which
we
(n)}
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
to
know
Proof.
Pick
any
consecutive

with
length
multiples
three,
which
n=1
ge
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
that
nds
A
and
B
in
an
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
Lemma
3.

Suppose
Suppose
we
we
already
already
know
know
that
that
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
is
a
a
NP-hard
NP-hard
problem.
problem.
Therefore,
Therefore,
we
we
can
can
show
show
ny consecutive
subsequence
of
F(a+
with
length
multiples
of
three
partitioned
into
multisets
algorithm
for
N+2),
=
36
is
unlikely
tocan
run
inb.
one
second,
wetwo
can,
use
awhich
O(2
Proof.
Proof.
The
The
proof
isis1),
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
us
uspartition
assume
assume
that
that
Vinto
Vinstance,

SSof
isis not
not
aa INDEPE
INDEP
any
consecutive
subsequence
of
FLet
with
length
multiples
three,
Proof.
{f
fby
(a
1),
f{f
+
...f
(b)}
for
some
aabe
<
We
can
F
into
multiples
of
three,
which
we
will
by
F
=
{f
(a),
fproof
+
f(a
(a
2),
...f
(b)}
for
some
<
b.
We
can
Ffor
radiction.
Therefore
Vdisjoint
(a),
S
isthree,
an
INDEPENDENT-SET.
denote
of
3.4
Finding
Special
Cases
F
with
length
multiples
of
which
we
will
denote
by
F
=
(aTheorem
+
1),
(a
+
2),
...f
(b)}
for
some
a
<SS
We
can
partition
into
=Pick
{f
(a),
ffin
(a
+
1),
ff(a
+
2),
...f
(b)}
for
some
apartition
<
b.b..isisWe
partition
FF F
into
F
will
denote
for
some
We
can
parti
on
of equal
F (N
)sum.
into
two
multisets
A
and
B
such
that
the
sum
of
allisE),
elements
N/2
b
a(a

2(a),
bE),

a
an
2We
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
denote
by
=
Proof.
A
Theorem
Theorem
1.
1.
1.
If
If
S
S

V
V
is
is
a
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
of
graph
graph
If
S

G(V,
G(V,
V
a
MAX-INDEPENDENT-SET
then
then
V
V

a
a
MIN-VERTEX-COVER
MIN-VERTEX-COVER
of
graph
G(V
is
sequence
is
dened
in
a
very
special
way,
the
sense
that
F
is
dened
using
the
of
equal
sum.
Pick
NDEPENDENT-SET
NDEPENDENT-SET
is
is
also
also
a
a
NP-hard
NP-hard
problem
problem
by
by
reducing
reducing
a
a
MIN-VERTEX-COVER
MIN-VERTEX-COVER
problem
problem
into
into
a
a
algorithm
for
solving
a
problem
like
SUBSET-SUM.
While
O(2
)
is
still
exponential
to
Therefore,
Therefore,
there
there
are
are
two
two
vertices
vertices
A,
A,
B
B

V
V

S
S
and
and
there
there
is
is
an
edge
edge
connecting
connecting
A
and
and
B.
B.
Since
Since
{f
(a),
f
+
1),
f
(a
+
2),
...f
(b)}
for
some
a
<
b.
can
partition
F
into
rtition
F can
into
ARTITION
problem.
PARTITION
from
SUBSETA
=
{f
(a +
3k),
0 into

k problem}isNP-hard
{f (a + 1by
+ reduction
3k), 0 bkb

}
<
b.
We
partition
F
tion
into
2 2
elements
in
B

2so

a
b

2
N
N
3
3
{f
(a),
fIfPick
(a
+
1),
f
(a
+
2),
...f
(b)}
for
some
a
<
b.
We
can
partition
F
into
orem
1. graph
Swe
thus
Vproblem.
is
a
MAX-INDEPENDENT-SET
of
graph
G(V,
E),
then
V

S
is
a
MIN-VERTEX-COVER
of
of
the
the
graph
G(V,
G(V,
E).
E).
of
the
graph
G(V,
E).
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
denote
by
F
=
Proof.
Therefore,
should
inspect
the
recurrence
formula
more
closely.
h
in
IOI,
and
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
PENDENT-SET
PENDENT-SET
problem.
b

2
b

2
b

O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(2
)
we
we have
havetoA,
A,
B
Bable

/
/Fany
S.
S.
As
A
A=and
and
B
B(a
are
are
connected
connected
by
by
an
an
edge,
edge,
we
note
note
that
S+
isis1three,
not
not
a k+
VERTEX-COV
VERTEX-CO
Alength
{f{f
(a
+
3k),
0+
k{f
}}we

(a
+that
11+
0+

}
=
+
3k),
0

{f
{f
(a
+
+S3k),
3k),
0
ak

valueconsecutive
of N , it is subsequence
unlikely
be
toAs
nd
an
algorithm
that
nds
A
and
B
in
an
Pick
consecutive
subsequence
of
Fwhich
with
length
multiples
of
which
we
wil
Proof.
A
=
(a
+
3k),
0

}
{f
(a
1
+
3k),
0

A
=
{f
(a
3k),
0

{f
(a
3k),
0

any
of
with
multiples
of
three,
we
will
denote
by
F
=
b

2
b

2
3
3
b

2
3
3
he
graph
G(V,
{f1(a),
fisapproach.
(a
+E).
1),
f
(a
+
2),
...f
(b)}
some
a}.
<sense
b.an
We
can
partition
F using
into3 the } {f
this
We
must
nd
afor
special
constraint
in 3k),
the
problem
such
use
a
2 3k),
b
ain

2
3 (a
A
=
{f
(a
+
0

+
1
+
3k),
0

contradiction.
contradiction.
Therefore
Therefore
V
V

S
S
is
is
an
INDEPENDENT-SET.
INDEPENDENT-SET.
a
+
+
0

k
}

B
=
{f
(a
+
2
+
3k),
0

sequence
dened
in
a
very
special
way,
the
that
F
is
dened
b
a

2
b

2
e Proof.
subsequence
of(b)}
F 1that
with
of
three
can
be
partitioned
two
{f
(a),
f0(a
(a
+
1),
f0(a
+
2),
(b)}
for
athat
<1into
b.
partition
F into

{f
(a
+
+ 3k),

kisproblem

}...f
1),
f (a +} We
2),
...f
for
some
a
<
We
can
partition
FWe
into
Proof.
Proof.
We
know
know
that
Vlength
V{f

S
S+multiples
is
ab.
a vertex
vertex
cover
by
by
lemma
lemma
know
1.
1.(a
The
The
only
only

thing
thing
that
a vertex
for
uslemma
to
to prove
prove
1. is
The
is its
itso
bVbWe

aS

acan
RTITION
problem.
PARTITION
isk cover
NP-hard
by
reduction
from
SUBSET3is2
3
}3k),
some
{f
+
3k),
0multisets
remains
A
3k),

{f
b cover
a for
2}byus
b
2that
2remains
oblem
to be
solvable
in =
polynomial
time.
can
check
additional
rst
rst
prove
the
the
following
following
two
two
lemmas.
lemmas.
3 prove
3We
}.ka
B3B
=
(a
+
22+
0+
k+k+

}.k
=
{f
(a
+
+whether
3k),
0
an

3.4
Finding
Special
Cases
herefore,
we
should
inspect
the
recurrence
formula
more
closely.
3
3
b
a
2
b

2
}.
B
=
{f
(a
2
+
3k),
0

}.
B
=
{f
(a
+
2
3k),
0

of.
We
know
that
V

S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
b

2
V
V

S
S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
V
there
there

S
is
is
is
another
another
not
minimum
vertex
vertex
cover
vertex
cover
V
V
cover.

S
S
where
Then,
where
minimality.
minimality.
Suppose
Suppose
minimality.
Suppose
3graph
alueb
of aN, 2it is unlikely
to{f
be1.
able
algorithm
that
nds
B
in
ank3G(V,
Theorem
Theorem
1.
Sto

isan
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
of
of
G(V,
E), 3then
then}VV
SS isisb a
a MIN-VE
MIN-VE
A as
=
(a
+
3k),
0VV2kis
kaaba2

}+22{f
02
E),
a2
b+A10and
a+
2a3graph
b 3k),

bIfIfS
nd
}.
B =b{f
(a
+(a
3k),
k
ll have
the
sum,
for
every
0a

{fsame
3(a
a3k),
isanother
}.

33k),
3 3k),
A
=
{f
+
0

{f
(a
+
1
+
0

k
A
=
(a
+
3k),
0

1
+
0
k

}
V

S
is
not
minimum
vertex
cover.
Then,
there
vertex
cover
V

S
where
mality.
Suppose
3
|V
|V

S
S
|
|
<
<
|V
|V

S|,
S|,
which
which
implies
implies
that
that
|S
|S
|
|
>
>
|V
|S|.
|S|.

S
By
By
|
<
lemma
lemma
|V

2,
2,
S|,
S
S
which
is
an
an
implies
independent
independent
that
|S
set.
set.
|
>
Therefore,
Therefore,
|S|.
By
lemma
S
S
is
is
not
not
2, S
aa}
If
If
S
S

V
V
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V

S
S
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
of
the
the
quence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
ba2
ba2
}.
B
=
{f
(a
+
2
+
3k),
0

of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
This
ismultiples
the
suitable
approach
in
IOI,
and
thus
is =
the main ba2
focus of this paper.
ubsequence
of F of
with
length
multiples
of most
three
can
be
partitioned
into
two
multisets
3
3
3
B
will
have
the
same
sum,
as
for
every
0

Aand
and
B
will
have
the
same
sum,
as
for
every
0

ve subsequence
FA
with
length
of
three,
which
we
will
denote
by
F
ba2
3
3
will
as for
3
3 3 0 k
b

2
A
and
B
will
have
the
same
sum,
as
for
every
A
and
B
have
the
same
sum,
every
0

Smaximum
| < |V
should
S|,
which
that
|S(a
>
lemma
2,
S
is
independent
isspecial
not a constr
maximum
independent
independent
set.
set.
This
This
a3k),
a|acontradiction.
contradiction.
maximum
Therefore
Therefore
independent
VVan

this
S
S
isisapproach.
the
This
minimum
isset.
a ba2
contradiction.
vertex
vertex
cover.
V S
3 SaTherefore
3Therefore,
E)
E)
erefore,
weba2
the
formula
closely.
3k)
Bb.fimplies
=
{f
+
2 is
+
0|S|.
kBy
more
b set.

athe

2minimum
(a
+(a
3k)
+
+
1F
+
=
f (a
+sum,
2 }.
+
and
IOI
we
need
to 3k)
use
must cover.
nd
bfis
2Friend,
Arecurrence
and
B2014
will
have
the
same
as
for
every
0
k We
..f
(b)}
for
some
a2inspect
<
We
can
partition
into
3 thing
3
0
k

}.
B
=
{f
(a
+
2
+
3k),
0

ba2
}.
B
=
{f
(a
+
+
3k),
0

Proof.
Proof.
We
We
know
know
that
that
V
V

S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
only
only
thing
that
that
remains
remains
for
for
us
us
imum
independent
set.
This
is
a
contradiction.
Therefore
V

S
is
the
minimum
vertex
cover.
3
A and B will have the same
sum,
asconstraint
for every allows
0k
fthe
+
fto
+
1f1+
+
3k)
=
+
+
3k)
f(a(aproblem
3k)
f(a(a
+solvable
+3k)
3k)
=ffpolynomial
f(a(a+
+12f2+
3k)
that
this
be
in
time.
We
can
3(a
3+3k)
fmultisets
(a
3k)
fif3k)
(a
2 +che
fthere
(a+
++
3k)
+
(a
1+
+
3k)
=
(a+
+MIN-VERTEX-CO
+
From
Fromthat
the
the
theorem,
we
we
conclude
conclude
that
that
aaTherefore,
From
MIN-VERTEX-COVER
MIN-VERTEX-COVER
the
above
theorem,
can
can
we
be
be
conclude
easily
easily
constructed
that
a
we
we+have
have
a3k
a
bsequence
of
FofVabove
with
multiples
of 3Vthree
can
be
partitioned
into
two
us
us
assume
assume
that
Vabove

with
Slength
Satheorem,
isislength
not
not
aaSuppose
VERTEX-COVER.
VERTEX-COVER.
Therefore,
there
are
are
two
two
vertices
vertices
A,
A,
B
Bconstructed

/
/isVV

SS2=+ifvertex
subsequence
F
multiples
of
three,
which
we
will
denote
by
F
=
ba2
V

S
S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
there
there
is
another
another
vertex
cover
cover
minimality.
minimality.
Suppose
b

2
b

2
(a + 1 + 3k) = f (a + 2 + 3k)
=
f (a
+
2B
+
3k)
A
and
will
have
the
same
sum,
as 1for
every
0kk 3 f (a}+ 3k) + fba2
f
(a
+
1
+
3k)
=
f
(a
+
2
+
3k)
a
+
3k),
0
k

{f
(a
+
+
3k),
0
ba2

vin
GUNAWAN

From
the
above
theorem,
we
conclude
that
a
MIN-VERTEX-COVER
can
be
easily
constructed
if
we
have
a
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
an
anMAX-INDEPENDENT-SET.
edge
edge
connecting
connecting
and
B.
B.
Since
Since
B
Binto

/3k)

/same
Vimplies
V+

fsum,
S,
S,
we
we
have
A,
A,
B
Bf
S.
S.
As
A
and
and
B
B is
are
are
connected
A
and
B
have
as
for3k)
every
0

+A
and
will
will
have
the
for
have
thesome
sameasum,
as
for|can
every
0 S|,

kA,
the
fA,
(a
+
(athat
+as
1have
+
(aBy
+klemma
2As
3k)
(b)}
for
<|V
b. A
We
partition
F
|V

S
|<
<
|V
|V

S|,
which
which
that
|S
|S
|3|every
>
>=
|S|.
|S|.
By
lemma
2, SS
is
an
anconnected
independent
independent set.
set. Theref
Theref
3 S
32,
3implies
Jonathan
Irvin
Jonathan
IrvinGUNAWAN
GUNAWAN
X-INDEPENDENT-SET.
we
we note
note that
that SS maximum
ismaximum
is not
not
an
INDEPENDENT-SET.
INDEPENDENT-SET.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V

S
S
is
is
a
a
Jonathan
Irvin
GUNAWAN
Jonathan
Irvin
GUNAWAN
b an
a
2
f
(a
+
3k)
+
f
(a
+
1
+
3k)
=
f
(a
+
2
+
3k)
independent
independent
set.
set.
This
Thiswhich
isis aa contradiction.
contradiction.
Therefore
Therefore
SS isis the
the minimum
minimum vertex
vertex cover.
cover
V
ubsequence
of0
multiples
three,
we
denote
F
=V
bFkwith
af(a
2length
bthe
will
2 MIN-VERTEX-COVER
}.
a + 2In
+ the
3k),
Jonathan
Irvin
GUNAWAN
f(a
+
3k)
+ fof(athis
+by1section,
+ 3k)
=we
f (a
2NP-hard
+we
3k)know
+
1ofassume
+
3k)
f
(a
+
2abeginning
+
3k)
Jonathan
Irvin
GUNAWAN
the
beginning
of
of
this
this
section,
section,
we
we
assume
we
In
know
know
that
that
assume
isis+
aa NP-hard
problem.
problem.
that MIN-V
ItIt isis
OVER.
OVER.
+
3k),
0In
k beginning

}+
3k)
{f
(a f+(a1 +
+
0 =kwe
}MIN-VERTEX-COVER
3
3k),
Jonathan
Irvin
GUNAWAN
b)} for some a < b. 3We
canthe
partition
Ftheorem,
into we
3isisthat
From
From
the
above
above
theorem,
we conclude
conclude
that
aa MIN-VERTEX-COVER
MIN-VERTEX-COVER
can
can
be
be easily
easily
constructe
n the
beginning
of
this
section,
we
assume
wepossible.
know
that
MIN-VERTEX-COVER
is aencounter
NP-hard
Itisconstructe
isnecessary
good
good
to
to know
know as
as many
many
NP-hard
NP-hard
problem
problem
as
as
possible.
good
to
This
This
know
necessary
necessary
as many
NP-hard
so
so that
that ififproblem
we
we
encounter
as possible.
aaproblem.
new
new
This
problem
problem
X,
X, we
we
ba2
Jonathan
Irvin
GUNAWAN
b

2
me
sum,
as
for
every
0

If
If
S
S

V
V
is
is
a
a
VERTEX-COVER
VERTEX-COVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V

S
S
is
is
an
an
INDEPENDENT-SET
INDEPENDENT-SET
of
of
the
the
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
3
by
the
construction
of
the
function.
dn to
many
problem
possible.
This
that if X,
we
encounter
a new
problem
X, we
bof

aNP-hard
NP-hard
2
bisreduce
necessary
a of
2itit the
Jonathan
Irvin as
GUNAWAN
can
can
use
useas
any
the
the
NP-hard
problems
that
that we
we know,
know,
can use
reduce
any
to
tosoproblem
problem
NP-hard
X,
problems
and
and thus
thusthat
prove
prove
wethat
that
know,
XX is
reduce
is also
also
NP-hard.
it
NP-hard.
to prob
}.problems
+
2GUNAWAN
+know
3k),
0any

kof
3k), 0 k
}3 {f (a + 1 + 3k), 0 k
}
E)
E)
use
any
of
the
NP-hard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NP-hard.
3
3
11We
1
f (a
3k)problem
+ f (aXX+isis1reducible
+ 3k) =to
(a + 2 Y
+
We
say
say+
that
that
problem
reducible
tofproblem
problem
Y 3k)We say that problem X is reducible to problem Y
the
the
beginning
beginning of
of this
this section,
section, we
we assume
assume we
we know
know that
that MIN-VERTEX-COVER
MIN-VERTEX-COVER isis aa NP-hard
NP-hard
In
a

2ba2
um, as
for everysimilar
0b
kIn
proof
proof
isisthat
actually
actually
to
to the
the
previous
lemma.
lemma.
Let
Let us
us assume
assume that
that VV
SS isis not
not aa INDEPENDENT-SET.
INDEPENDENT-SET.
We
X is reducible
to problem
Y
}.3previous
2 +say
3k),
0 problem
k similar
good
good3 to
to know
know as
as many
many NP-hard
NP-hard problem
problem as
as possible.
possible. This
This isis necessary
necessary so
so that
that ifif we
we encounter
encounter aa new
new
here
here are
two
vertices
vertices
A,
B
3k)
VV

SSfand
and+there
there
isis an
an edge
edge connecting
connecting A
A and
and B.
B. Since
Since A,
A,B
B VV
S,
S,
fare
(atwo
+ 3k)
+ fcan
(aA,
+
1Bany
+
=
(a
2 + problems
3k)
can
use
use
any
of
of
the
the
NP-hard
NP-hard
problems
that
that
we
we
know,
know,
reduce
reduce
it
it
to
to
problem
problem
X,
X,
and
and
thus
thus
prove
prove
that
that
XX ii
ba2
B
B
/
/as
S.
S.for
As
Asevery
A
A and
and
B
Bkare
are
connected
by
by an
an edge,
edge, we
we note
note that
that SS isis not
not aa VERTEX-COVER.
VERTEX-COVER. This
This isis aa
m,
0
connected
3
11We
We
say
that
that problem
problem XX isis reducible
reducible to
to problem
problem YY
n.
n. Therefore
Therefore VV
SS isis
an
ansay
INDEPENDENT-SET.
INDEPENDENT-SET.

ICPC
World
Finals
2010
Solutions
n.d.).
at problem.
we
use
tosolvable
nd
all
possible
paths
(ACM
to be
in
polynomial
time
using
the
reduction
ofgiven
the
original
problem
(withemadditional
constraint),
and
check
whether
the
proof
stillproof
holds
the
additional
constraint
to the problem.
onstraint),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
toIfthe
re
that
we
can2
get
Accepted
by
only
"hacking"
a complete
search
algorithm.
Therefore,
we through
ollowing
formula
2
Identifying
Identifying
Intractability
Intractability
of
a
Problem
of
a
Problem
through
Reduction
Redu
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
int), and check whether the proof still holds given the additional constraint to the problem.
causes ainproblem
to be solvable in polynomial time using the reduction proof of the original problem (withchnique
detail.
wever,
it
is
not
very
suitable
for
IOI.
Usually,
IOI
problems
require
deep
analysis
from

e one
will example
give
we one
ofwhether
a in
special
inproblem.
a NP-hard
problem.
Suppose
we havewith
a function
with the
editional
of a example
special
case
a NP-hard
Suppose
weadditional
have
a function
the problem.
constraint),
and
check
thecase
proof
still
holds
given
the
the
We
likewould
to
know
likeonly
that
to know
the problem
that
that
problem
we
are
that
attempting
we
are
attempting
unlikely
unlikely
havetoan
to
immediate
have an immediate
solution. solu
The
1,athe
n=
1is
n = constraint
2is to
at
weformula
canwould
getaWe
Accepted
by
"hacking"
complete
search
algorithm.
Therefore,
we
example
of
special case
in a NP-hard
problem.
Suppose
we
have
a
function
with
the
ing
f (n) = Understanding Unsolvable Problem
93
most
common
most
common
way
is
to
way
apply
is
to
a
well-known
apply
a
well-known
technique
technique
called
reduction.
called
reduction.
Suppose
Suppose
we
know
we
that
know
problem
that
pro
X
i
Finding
Small
f (n 1) + f (n 2), n > 2
ue in detail.3.3by the
construction
of
theConstraints
function.
case
of
1
1
l give
we oneimpossible
example
asolve,
special
in
a know
NP-hard
problem.
Suppose
we
have
ausing
function
with
the
impossible
to
solve,
to
and
we
also
and
know
we
also
that
we
can
that
solve
we
can
problem
solve
X
problem
by
using
X
problem
by
Y
problem
as
a
black-box
Y
as
a
black-box
.
If
we
can
.
by
the
construction
of
then function.
by
construction
of
the
bysequence
the
construction
of time
the
function.
function.
1,
1
=
2rst
1,
n
=dene
1then
solve
n F=
2n
) SUBSET-SUM
algorithm
running
for
various
input
sizes.
This
the
We
consider
the
=
{f
, and
weX
(N
)=well.
to
bebe
the
ofimpossible
F
We impossible
want
to know
NP-hard
with
large
Ncan
that
is
impossible
to
exponentially
(e.g.NY
Nterms
>
50).
Theorem
2.FIf
=
is(n)}
divisible
by
three,
can
partitioned
two
multisets
ormula
n=1
fwe
(n)
fthe
(n)function.
=
solveproblem
problem
Y,
problem
then
Y,
then
solve
we
can
problem
solve
problem
as
well.
X
Therefore,
as
Therefore,
problem
problem
isinto
also
is .also
to solve.
to solve
Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into Y
two
multisets
of equal
sum.
nstruction
of solve
by
the
construction
of
the
function.
by
the
construction
of
the
function.
1,
n
=
1

n
=
2
3.3
Finding
Small
Constraints
f
N
on
a
MacBook
Pro
(Retina,
13-inch,
Early
2015)
f
(n

1)
+
f
(n

2),
n
>
2
fpartition
(n
N
1)
+
fSUBSET-SUM
(n
2),
n >algorithm
2then
hether
can
asum.
of
Fthat
(Nfunction.
)may
into
two
disjoint
A
suchproblem
that
the
sum
allpartitioned
elements
ofcreate
equal
also
lookwe
small
constraints
For
acan
SUBSET-SUM
N
N/2
Theorem
2.example,
IfF
N
is)) can
divisible
by
then
F
(N
) canof
be
int
by
the
of
the
Theorem
2.
IfIf
by
three,
(N
be
partitioned
into
two
multisets
of
equal
f for
(n)
=
Theorem
2.
N
is
divisible
byhelp.
three,
then
Fmultisets
(N
beand
partitioned
into
two
multisets
of
equal sum.
sum.
omparison
ofother
O(2
)construction
and
O(2
) divisible
running
time
forBthree,
various
input
sizes.
This
is
by
construction
of
the
function.
fthe
(n
the
1)
+
felements
(n

2),
n
>
2
by
the
construction
of
the
function.
by
construction
of
the
function.
by
the
construction
of
the
function.
nrd
A
is
equal
to
the
sum
of
all
in
B
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
that

Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemm
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
1,
n
=
1

n
=
2

Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
by
the
construction
of
the
function.
Theorem
2.
Ifthen
N
isthe
divisible
by
three,
F>
(N
) problems
can
partitioned
into
two mult
is run
100
times
for
each
value
N, and
on
a(N
MacBook
13-inch,
Early
2015)
nsider
the
F
=
we
dene
FPro
(N
)(Retina,
the
rst
terms
of
F
.be
We
want
totoknow
We=sequence
are
using
We
are
NP-hard
using
problems
NP-hard
problems
for
illustration.
for
Recall
Recall
NP-hard
that
problems
NP-hard
have
yet
to
have
be of
yet
solved
be
in polynomia
solved
in p
quence
F
{fProof.
(n)}
,N
and
we
dene
F three,
) to
to
beillustration.
rst
Nabe
terms
ofthen
FN
We
want
tomultiples
know
rd
problem
with
large
that
isof
impossible
solve
exponentially
(e.g.
50).
If
{f
is=(n)}
divisible
by
to
isthat
prefix
of
.N
with
length
n=1
fN
(n)
2 length
Proof.
Ifof
N(N
is))F
divisible
bybe
three,
then
Finto
(N multiples
)multiples
is amultisets
prex
F equal
with
length
Theorem
2. is
Ifdivisible
N
isn=1
divisible
by
three,
can
partitioned
two
of
sum.
Proof.
IfIf
by
three,
then
F
is
aa )prex
of
F
of
three.
By
Proof.
N
is[0,
divisible
by
three,
then
Fthen
(N
is(N
prex
of
F with
with
length
of of
three.
By lemma
lemm

the
array
are
small
(e.g.
100]),
this
problem
can
be
solved
using
O(N
X
)to
Dynamic
can
be
partitioned
into
two
multisets
equal
sum..
f
(n

1)
+
f
(n

2),
n
>
2
eer
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
know
polynomial
time
using
the
reduction
proof
of
the
original
problem
(withwe
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
three.
By
lemma
3,

can
be
partitioned
into
two
multisets
of
equal
sum.
time
for
more
time
for
than
more
4
decades.
than
4
decades.
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
a
graph
is
problem
a
graph
that
problem
involves
that
nding
involves
a
nding
minimum
a
minimu
subse
ate
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
ook
for
other
small
constraints
that
may
help.
For
example,
a
SUBSET-SUM
problem
Theorem
If
N
divisible
bypartitioned
three,
then
(N
)be
can
be
partitioned
into
of equa
n=1
Theorem
2.can
IfF
N
is))F
by
three,
then
F
(N
)two
besum.
partitioned
Theorem
2.
N
is)divisible
divisible
by
three,
Fsum..
(N
can
be
partitioned
into
two
multisets
of three.
equal
sum
Theorem
2.
IfIfN
N
is
by
three,
then
(N
can
partitioned
into
two
multisets
of
equal
sum
Nfunction.
isthe
divisible
by
three,
then
F2.
(N
istwo
aisIfproblem.
prex
of
multiples
of
By
lemma
3,can
Fmultisets
(N
)of
Ifelements
is
then
F
(N
)problem
isdivisible
a prex
of
length
Byin
Theorem
2. be
IfProof.
N
isthe
divisible
bydivisible
three,
then
(N
)then
be
partitioned
into
two
multisets
of
equal
can
beFF
into
two
ofprex
equal
sum..
Proof.
Nby
isthree,
divisible
bylength
three,
then
Fmultisets
(N
)three.
isF
awith
of
F multiples
with
length
multiples
can
be
partitioned
into
multisets
of
equal
can
be
partitioned
into
two
multisets
ofwith
equal
sum..
looks
like
classic
PARTITION
PARTITION
isthe
NP-hard
by
reduction
from
SUBSETX
isThis
upper
bound
of
inside
the
array.
Even
though
the
running
time
of
the
then
Fnodes
(N
)will
can
partitioned
into
two
multisets
of
equal
sum.
partition
ofthe
Fcan
(N
)aholds
into
two
disjoint
multisets
Athen
and
Bequal
such
that
the
sum
of
allin
elements
ther
the
proof
still
given
the
additional
constraint
to
the
problem.
s
equal
to
sum
of
all
elements
in
B
of
of
such
nodes
that
such
for
every
that
for
edge,
every
at
least
edge,
one
at
least
of
its
one
endpoint
of
its
endpoint
is
in
subset.
is
the
MAX-INDEPENDENT-SET
subset.
MAX-INDEPENDENT
is a
e
sum
of
all
elements
in
B
oblem,
and
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
that
Proof.
If
N
is
divisible
by
three,
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma

then
F
(N
)
be
partitioned
into
two
multisets
of
sum.
3.the
If
N

1 be
(mod
3),
F
(N
))to
bebeof
partitioned
into
two
multisets
of(withequal
sum.
er
the
F
=
{f
(n)}
,can
and
we
dene
Fusing
(N
to
be
the
rst
Nofconstraint.
terms
of
FAnother
. We
want
to
know
artitioned
intoofTheorem
two
ofalgorithm
equal
sum..
asequence
problem
toofmultisets
be
solvable
in
polynomial
time
the
reduction
proof
ofalgorithm
the
original
problem
nto
two
multisets
sum.
Theorem
3.
If
,three,
cannot
cannot
partitioned
into
two
multisets
of
can
be
partitioned
into
two
multisets
of
equal
sum..
into
two
multisets
equal
sum..
n=1
UM.
Therefore,
aequal
large
value
of
N
,ispartitioned
it
is
unlikely
be
able
to
an
that
nds
A
Bfunction.
inBy
anlengt
lauses
tothe
the
size
the
input,
still
fast
enough
for
the
given
sible
by
three,
then
F
(N
)100]),
can
be
partitioned
into
two
multisets
equal
sum.
Proof.
If
N
isthe
divisible
by
then
F
(N
)partitioned
isO(N
and
prex
of
F
with
length
multiples
of
three.
By
2
by
the
construction
the
Proof.
Ifnodes
N
is
divisible
by
three,
then
F
(N
)of
isbe
aone
prex
of
F
with
Proof.
N
is
divisible
by
three,
then
F
(N
is
aF
prex
of
F
with
length
multiples
ofand
three.
By
lemm
Proof.
IfIf
N
is
divisible
by
three,
then
F
(N
))of
is
a
prex
of
F
with
length
multiples
of
three.
lemm
by
the
construction
of
the
function.
by
construction
the
function.
by
construction
of
the
function.
of
all
elements
infor
B
graph
problem
graph
of
problem
nding
of
a
nding
maximum
a
maximum
subset
of
subset
such
nodes
that
such
for
every
that
for
edge,
every
at
most
edge,
at
most
of
its
one
endpoint
of
its
endp
is
in
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
with
length
multiples
three.
By
lemma
3,
F
(N
array
are
small
(e.g.
[0,
this
problem
can
be
solved
using
X
)
Dynamic
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
partitioned
into
two
m
can
be
partitioned
into
two
multisets
of
equal
sum..
Theorem
3.
If
N

1
(mod
3),
F
(N
)
cannot
be
into
two
multisets
of
equal
sum.
the
construction
of
the
function.
Theorem
3.
If
N

1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
ecient
aHowever,
partition
ofofFN
(N
into
two
disjoint
multisets
A and
Bexample,
the sum
all
elements
equal
sum.
Fcan
(N))create
isway.
a prex
prex
ofand
F check
with
length
multiples
ofstill
three.
By
lemma
3,
Fsuch
(N
)that
itional
constraint),
whether
the
proof
holds
given
the
additional
constraint
toNofFthe
problem.
this
sequence
is
dened
in
athat
very
special
way,
in
the
sense
that
is
dened
using
the
not
F (N
nique
is
when
the
value
is)inside
too
large
(e.g.
N
<
40).
For
while
O(2
)elements.
F
(N
is
a
of
F
with
length
multiples
of
three.
By
lemma
3,
)contains
can
be
partitioned
into
two
multisets
of
equal
sum..
n.
can
be
partitioned
into
two
multisets
of
equal
sum..
can
be
partitioned
into
two
multisets
of
equal
sum..
can
be
partitioned
into
two
multisets
of
equal
sum..
Proof.
Suppose
F
(N
)
=
F
(N
)

f
(1).
Note
that
F
(N
)
N

1
Since
N

1
(m
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
l
case
in
a
NP-hard
problem.
Suppose
we
have
a
function
with
the
th
multiples
of
three.
By
lemma
3,
F
(N
)
Theorem
3.
If
N

1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
his
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSETthe
subset.
the
Suppose
subset.
we
Suppose
already
we
know
already
that
know
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
a
NP-hard
is
a
NP-hard
problem.
problem.
Therefore,
Therefore,
we
can
show
we
can
be
partitioned
into
two
multisets
of
equal
sum..
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSEThe
upper
bound
of
the
elements
the
array.
Even
though
the
running
time
of
the
Theorem
3.
If
N

1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
e
yis
three,
then
F
(Nall
is
a3.
prex
of
F1 )can,
with
length
multiples
ofby
three.
By
lemma
3,
FNMiddle
(N
)1of
ual
to the
sum
of
elements
in
B
of
equal
sum..
three,
Fdivisible
Theorem
2.
Ifthen
Nsum.
is
by
three
N/2

=
Theorem
2.
If
N
istwo
divisible
by
three,
(N
) can
be
part
(N
Theorem
2.
If
N
is)divisible
divisible
by
three,
then
F(N
(N
)fis
can
be
partitioned
into
two
multisets
equal
sum.
Theorem
2.
If
N
divisible
then
F
(N
)two
can
be
partitioned
into
two
multise
Proof.
Suppose
F
(N
)
F
(N
)

f
(1).
Note
that
F
(N
)
contains
N

forementioned
recurrence.
Therefore,
we
should
inspect
recurrence
formula
more
closely.
Theorem
If
N
(mod
3),
F
(N
)
cannot
be
partitioned
into
multisets
of
equal
sum.
the
Proof.
Suppose
F
(N
=
F
(N
)

(1).
Note
that
F
(N
)
contains

elements.
Since
N

1
(m
unlikely
to
run
in
one
second,
we
for
instance,
use
a
O(2
)
Meet
In
The
Proof.
Suppose
F
(N
)
=
F
(N
)

f
(1).
Note
that
F
)
contains
N

1
elements.
Since
N

1
(m
heorem
2.
If
N
is
by
three,
then
F
)
can
be
partitioned
into
multisets
of
equal
f
equal
sum..
Proof.
Suppose
.
Note
that

contains

elements.
n.
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
The
sic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSETTherefore,
for
aoflarge
of3.NIfis,case
itstill
is
unlikely
to
be
able
to nd
an
algorithm
that
nds
Awith
and the
Bofin
an sum.
that
that
MAX-INDEPENDENT-SET
is
also
aNP-hard
NP-hard
is
also
aproblem.
NP-hard
problem
by
problem
reducing
by
reducing
ahave
MIN-VERTEX-COVER
aB
MIN-VERTEX-COVER
problem
into
probla
or
asize
large
value
N
,sum..
itvalue
is
unlikely
be
able
to
nd
an
algorithm
that
nds
and
in multisets
an
he
ofMAX-INDEPENDENT-SET
the
input,
the
algorithm
fast
enough
the
given
constraint.
Another
one
wo
multisets
equal
(mod
3),into
Theorem
N
1two
(mod
3),
cannot
be
partitioned
into
two
equal
give
we
example
of
a1fSuppose
special
in
we
a)N
function
N
hree,
then
Fof
)Fcan
partitioned
multisets
sum.
Theorem
If)F
N

13).
FA
(N
cannot
be
partitioned
into
two
m
Theorem
3.
N
3),
13).
(mod
3),
F)F(N
(N
)F
cannot
be
partitioned
into
two
multisets
ofbe
equal
sum.
Theorem
3.
IfIfWhile
N

1to
3),
F
)for
cannot
be
partitioned
two
multisets
of
equal
sum.
3.
rtitioned
into
two
multisets
of
equal
sum.
of
uppose
Flike
(N
)(N
=
(N
)be
elements
Note
that
(N
contains

1be
elements.
Since

1)F)can
(mod
3),
we
Proof.
F
(N
)have
=
Fstill
(N
)sum.

(1).
Note
that
FA
(N
)elements
contains

1sum.
elements.
Since
N

Theorem
3.
If
N

(mod
F
(N
)aF
cannot
be
partitioned
into
two
multisets
equal
haveN

1F

(mod
By
lemma
3,
Ftwo
(N
be
partitioned
into
tw
Proof.
Suppose
(N
)f(N
=0)equal
(N
)Suppose

(1).
Note
that
Fof
(N
contains
N

1sum.
element
N/2
equal
problem
SUBSET-SUM.
O(2
is
exponential
to
N
,fpartitioned
it
isof
much
faster
than
haveN

11sequence

0(1).
(mod
3).
By
lemma
3,
F
(N
can
into
multisets
of
equal
The
Since
,into
we
.(mod
By
lemma
3,
is(N
can
haveN
all

0not
(mod
By
lemma
3,
(N
)N
can
be
partitioned
into
two
multisets
of
sum.
The
Nin
sum
of
in
F
(N
)
is
even.
However,
the
sum
all
in
)
=
F
(N
)
+
f
(1),
wh
arge
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
that
and
B
an
))ever,
cannot
be
partitioned
into
two
multisets
of
equal
too
nds
Proof.
If
N
divisible
by
three,
nt
way.
However,
this
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
MAX-INDEPENDENT-SET
MAX-INDEPENDENT-SET
problem.
problem.
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
is
when
the
value
of
N
is
large
(e.g.
N
<
40).
For
example,
while
O(2
)
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F(m
w
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)then
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
emma
3.
Proof.
Suppose
F
)
=
F
(N
)

f
(1).
Note
that
F
(N
)
contains
N

1
elements.
Since
N

1
(N
oof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.

oks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSEThree,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
ormula

1ofN
03),
(mod
3).
By
lemma
3,
F
(N
)F
can
partitioned
into
two
of
equal
sum.
Therefore,
multisets
of
equal
sum.
haveN
1very

(mod
3).
By
lemma
3,equal
FTherefore,
(N
)multisets
can
be
into
two
equal
sum
of
all
elements
F
)F
is
even.
However,
the
sum
of
all
elements
haveN
multiples
1))way,

0using
(mod
3).
By
lemma
3,dened
(N
can
be
partitioned
into
multisets
partitioned
into
two
multisets
of
equal
sum.
the
sum
of
all
elements
in
twice
(N
partitioned
that
can
solve
is
the
range
of
N
aaformula
O(2
)partitioned
solution.
sum
of
all
elements
in
)be
is
However,
the
of
all
elements
in
(N
=
F
(N
)of
+
ff(1),
wh
in
the
0
sum
of
all
elements
in
F
(N
is
However,
the
sum
of
all
elements
in
F
(N
)multisets
=
F
(N
)contains
+Since
(1),
wh
we
(N
by
the
construction
the
function.
nSuppose
=
1
n
=
2special
mod
F
(N
cannot
be
partitioned
two
multisets
of
sum.
because
F
(N
)=
is
even
while
fsum
(1)
isinto
odd.
Therefore,
there
is
no
to
partition
F
(N
).
Proof.
Suppose
F
(N
=
F
(N
)(1).

(1).
Note
that
F
(N
))1can
contains

1)equal
elements.
N

this
sequence
dened
in
a
in
the
sense
that
Fsum
is
using
the
of
N/2
f
be
partitioned
into
two
multisets
mentioned
recurrence.
Therefore,
should
inspect
the
recurrence
formula
more
closely.
then
F
(N
)itaSuppose
is
ais
prex
of
F
with
length
three.
By
lemma
3,
F
(N
)way
Proof.
Suppose
F
(N
)F
=
F
)

felements.
(1).
Note
that
FN
)1two
Proof.
Suppose
F
(N
)of
=
F
(N
)even.

Note
that
(N
)(N
contains
N

1F
elements.
Since
N
The
(m
Proof.
F
(N
)into
=
(N
)even.

ffof
(1).
Note
that
F
(N
)into
contains
N

1N
elements.
Since
N

11N
(m
urrence.
Therefore,
we
should
inspect
the
recurrence
more
closely.
ikely
to
run
in)multiples
one
second,
we
can,
for
instance,
use
O(2
Meet
In
The
with
length
three.
By
lemma
3,
can
be
two
multisets
of
sum..
can
be
partitioned
into
two
equal
sum..
can
be
partitioned
two
of
equal
sum..
frefore,
equal
sum.
Proof.
F
(N
)all
F
(N
)unlikely

fF
(1).
Note
that
F
))an
contains
N
Since

(mod
w
haveN

1of

0multisets
(mod
3).
By
lemma
3,
F
(N
)(N
can
be
partitioned
into
two
of(N
equal
into
Middle
be
partitioned
two
multisets
of
equal
sum..
sum.3),
for
large
value
of
N
,elements
it
is
to
be
able
to
nd
algorithm
that
nds
Amultisets
and
B
in
an
elements
multisets
of

ln).
elements
in
F
)
is
even.
However,
the
sum
of
all
in
F
(N
)
=
F
(N
)
+
f
(1),
which
is
odd
1).
Note
that
F
(N
)
contains
N

1
elements.
Since
N
1
(mod
3),
we
sum
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
)
=
F
(N
)
+
f
(p

is
even.
However,
the
sum
of
all
elements
in
,
which
is
because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
(N
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=

because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
by
the
construction
of
the
function.

because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
more
N/2
Note
that
F
(N
)
contains
N

1
elements.
Since
N

1
(mod
3),
we
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum
ce.
Therefore,
we
should
inspect
the
recurrence
formula
closely.
hen
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)

sets
of
equal
sum..
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
tw
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Th
We
will
rst
We
prove
will
rst
the
prove
following
the
following
two
lemmas.
two
lemmas.
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Th
em
SUBSET-SUM.
O(2
) (N
is
still
tobe
Npartitioned
, nitthe
is
faster
than
n

1)
+
f (n

2),
nisWhile
>
213).is
F(N
1Theorem
elements.
Since
N

haveN
be
1this

0sequence
By
lemma
3,
Fexponential
(N
)(1)
can
be
partitioned
into
two
of
equal
sum.
Therefore,
th
(mod
sum
all
elements
F
)while
is
even.
However,
the
sum
of
all
elements
in to
F
(N
)two
=
F
) +). f3),
(1),F (N
wh
1,two
n
=
1to
=
2much
like
N
ay.
However,
dened
inwith
very
special
way,
in
sense
that
F
is
dened
using
the
Ifof
N
divisible
by
three,
then
F
(N
))multiples
can
two
multisets
equal
sum.
while
Any
subsequence
of
Fwe
length
of
three
can
partitioned
into
multisets
ma
3.
=
(N
)is)can
fconsecutive
(1).
Note
that
Finto
(N
)
contains
N

1
elements.
Since
N

1into
(mod
3),
we
Theorem
4.
If
2is
(mod
3).
F
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
subsequence
of
F
with
length
of
can
be
partitioned
into
two
multisets
F
) Pick
even
while
f1(mod
is=
odd.
Therefore,
there
is
no
way
partition
F
(N
).
,nsecutive
(N
partitioned
multisets
of
equal
sum.
Therefore,
the
odd
because
in
is3),
even
length
is
odd.
Therefore,
there
is
no
way
partition
because
Fsubsequence
(N
)(N
even
f
is
odd.
there
ismultisets
no
way
to
partition
F
(N
Theorem
3.
Ifin
N
1)(N
(mod
because
Faof
(N
)be
is
even
while
fTherefore,
(1)
is
Therefore,
there
is
no
way
partition
F
Theorem
3.
If
N
1be
(mod
3),
Fwe
(N
)of
cannot
be
partitioned
i(
F

Theorem
3.
If2.
N

(mod
3),
F
)F
cannot
partitioned
into
two
multisets
of
equal
sum.
any
consecutive
with
multiples
of
three,
which
will
denote
by
F
=
roof.
odd.
to
multiples
multisets
N
Theorem
3.
If
N
1three
(mod
3),
F
(N
)the
cannot
be
partitioned
into
two
of
equ
f(1)
(n)
heorem
3.
Ifsolve
N

1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
,ets
F of
(N
)can
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
3.4
Finding
Special
Cases
sum
all
elements
in
F
(N
)
is
even.
However,
sum
of
all
elements
F
(N
=
F
(N
)
+
f
equal
sum..
range
(N
of
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
sum
of
all
elements
in
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
f
(1),
w
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
)
=
F
(N
)
+
f
(1),
w
that
it
is
twice
the
of
N
using
a
O(2
)
solution.
wo
multisets
of
equal
sum.
Therefore,
the
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
f
(1),
which
is
od

Theorem
4.
If
know
2then
(mod
3).
F
(N
)
can
be
partitioned
intomultisets
twoofmult
because
F
(N
)Sinto
is
while
ff3).
(1)
is (N
odd.
Therefore,
there
no
way
tothen
partition
F is
(N
).sum.
F
Theorem
4.
If
N

22N
(mod
F
(N
)) +
can
be
partitioned
into
two
multisets
of
equal
Theorem
2.
If+
N
is
divisible
by
three,
Fis
(N
)closely.
can
be
partitioned
into
two
o(
Theorem
4.
If
N

(mod
3).
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
E),
tive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
feven
(n

1)
(n

n
>
2Nto
we
dene
Fsum
)of
be
the
rst
terms
of
F
We
want
ual
sum.
By
lemma
3,
Ff(N
(N
)to
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
.of
However,
the
all
elements
in
F
(N
)
=
F
)
f
(1),
which
is
odd
F
(N
)
cannot
be
partitioned
two
multisets
of
equal
sum.
Lemma
1.
Lemma
1.
If
S

V
If
is
an

INDEPENDENT-SET
V
is
an
INDEPENDENT-SET
of
graph
of
G(V,
graph
G(V,
then
E),
V
S
is
V
a

VERTEX-COVER
S
a
VERTEX-COV
the
dand
into
two
multisets
equal
sum.
.2),

foned
(a),
f
(a
+
1),
(a
+
2),
...f
(b)}
for
some
a
<
b.
We
can
partition
F
into

(N
sum
elements
in
F
(N
)4.
=
F
) B.
+
fSince
(1),
which
isof
odd
(N
because
F
(N
is(1).
even
while
f3).
(1)
is
odd.
Therefore,
is
no
way
to
partition
F=
(NFF
).
If=2N
by
then
F
(N
)Therefore,
is
a
prex
ofcan
F
with
length
multiples
of
three.
By
lemma
3,
is
there
Fway
F
(N
)contains
isSuppose
even
while
fiselements.
(1)
odd.
Therefore,
there
no
to
because
FF
(N
is
even
while
(1)
isto
odd.
Therefore,
there
no
way
to
partition
F
(N
).
because
F
(N
)f)which
is
even
while
fffbecause
(1)
is
odd.
Therefore,
there
way
to
partition
F
).
divisible
Proof.
(N
now
Proof.
Assign
(1)
A
and
(2)
fisbe
(1)
=
f
we
are
partition
(N
4.
If
N
(mod
3).
(N
))three,
can
be
partitioned
into
two
multisets
sum.
sHowever,
inProof.
F
(N
)the
F
(N
)Theorem
+
fno
(1),
is
odd
4.
If
N

2Note
(mod
F
(N
)(N
partitioned
into
multisets
equal
sum.
Proof.
Suppose
F
(N
)multisets
(N
)F

f) )(=
IOI,
because
F
(N
)of
is
while
f)to
(1)
is
odd.
there
to
partition
F
(N
).into
)3).
Theorem
Ifthat
N
2=
FN
(N
)equal
can
be
partitioned
two
of
equ
(N
)no
=
F
(N
)Since

(1).
Note
that
(N
) con
Suppose
F
(N
)all
=
F
(N
)
fall
F
(N
)paper.
N
1is
N
1of
(mod
3),
we
Proof.
Suppose
Fin
(N
)(N
F
(1).
Note
that
Ftwo
(N
)ftrying
contains
N
is13),
elements.
ble
approach
in
and
thus
is
main
focus
of
this
To
solve
IOI
2008
Island
nto
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
oof.
Suppose
Fthere
(N
){f
=even
F
(N
fthe
(1).
Note
that
FFAssign
contains
F
1(2),
elements.
Since
N
1to
(mod
we
(N
)two
is
even.
However,
the
sum
of
elements
(N
))(mod
=
F
(N
)fno
+
fway
(1),
which
is
odd
FProof.
(N
)Therefore,
cannot
be
partitioned
into
two
multisets
of
equal
sum.
dd.
is
way
to
partition
F
(N
).

graph
G(V,
graph
E)
G(V,
E)
are no
we
denote
Proof.
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
Theorem
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
.onsecutive
r
the
sequence
F
=
(n)}
,
and
we
dene
to
be
the
rst
N
terms
of
F
.
We
want
to
know

Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
Theorem
4.
If
.

can
be
partitioned
multisets
of
equal
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
thre
dd.
Therefore,
there
is
no
way
to
partition
F
(N
).

Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
can
be
partitioned
into
two
multisets
of
equal
sum..

Pick
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
by
F
=
n=1
subsequence
of
F
with
length
multiples
of
three,
which
we
denote
by
Fthe
bnd

aa2
23).
blemma

a 1obtain

2=
f(mod
(1)
3).
fapproach.
(2).
F
(N
)We
will
have
N

elements.
Since
N
2will
(mod
3),
we
N

0By
(mod
3).
partition
F
).
haveN

3,
0function.
3).
lemma

f (1).
Note
F
(N
) Since
contains
N

12
elements.
Since
Nlemma

1be
(mod
3),
we
by
the
construction
of
1
ontains
10that
elements.

(mod
3),
we
haveN

0partitioned
(mod
By
F(mod
(N
) 2equal
can
be
partition
1N
1

(mod
3).
By
3,1
F
(N
)can
can
be
partitioned
into
two
multisets
equal
sum.
Therefore,
the mu
3.4
Finding
Special
Cases
haveN
0to
(mod
By
3,
Fthe
(N
)3).
can
be
partitioned
into
two
multisets
of3
we
need
to
use
this
must
special
constraint
in
problem
such
BhaveN
veN

0(N
By
lemma
3,
F
(N
)(mod
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
hile
fTheorem
(1)
is
odd.
Therefore,
there
is
no
way
partition
F
(N
).
Theorem
4.
Ifpartitioned
N

3).
F
(N
)A
can
into
two
multisets
of
sum.
be
Theorem
4.
If
N
2B
(mod
3).
F
(N
)of
be
partitioned
into
two
Theorem
4.
Iflemma
NN

(mod
3).
F
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
Theorem
4.
If
N

22
(mod
3).
F
(N
)})we
can
partitioned
into
two
multisets
of
equal
sum.
A
=
{f
(a
+
3k),
0
k

{f
(a
+
1
+
3k),
0

}
can

ssign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
(2),
are
now
trying
to
partition
F
(N
)
=
F
(N
)

Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
um.
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
and
such
that
the
sum
of
all
elements
sum.

f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N

0
(mod
3).
can
be
into
two
multisets
of
equal
sum..

f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N

0
(mod
3).

utive
subsequence
FF
length
multiples
of
we
will
denote
by
F
with
even.
,aum
(a
+
1),
f(b)}
for
some
aHowever,
<
b.
We
can
partition
F
into
2),
...f
some
acontains
<
b.
We
can
partition
Fthree,
into
a which
3,+for
F2),
(N
) (N
can
be
partitioned
into
multisets
of
equal
which
our
theorem.
3two
3of

(1).
Note
Fof
(N
)(b)}
N

1
elements.
Since
N

1elements
(mod
3),
we
)ff+
can
be
partitioned
into
two
multisets
of
equal
sum.
sum
of
all
elements
inwhich
Fthe
)(N
is (N
ma
3,
F
(N
)(athat
can
be
partitioned
into
two
multisets
of
equal
Therefore,
the
Proof.
Proof.
Let
us
assume
Let
us
that
assume
V

that
S
is
not

S
athe
VERTEX-COVER.
is
not
VERTEX-COVER.
Therefore,
Therefore,
there
are
two
are
two
A,
vertices
B

/odd
V)even.
A,

BF
S
oned
two
multisets
of
equal
sum.
Therefore,
the
sum
of
in
F(N
(N
)implies
is
sum
of
ofinto
all
elements
in...f
(N
)fis
is
even.
the
sum
of
all
elements
in
F(N
)=
=
F (N
(N
)+
+fHowever,
fvertices
(1),
sum
all
elements
in
F
(N
)sum.
isall
However,
the
sum
all
elements
in(N
Fis
=
ows
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
additional
Proof.
Assign
(1)
and
fN
(2)
to
B.
Since
feven.
(1)
=
fsum,
(2),
we
are
now
trying
to
partition
F
)all
=
be
m
of
all
elements
F
even.
However,
sum
of
all
elements
in
F
F
)there
(1),
which
odd
)2).
can
partitioned
into
two
multisets
of
equal
of
Theorem
3.
If
N

1
(mod
3),
FA
(N
)V
cannot
be
partitioned
into
two
multisets
of
equal
sum.
sum.
in
F
Fthe
(N
)for
will
have
N

2)We
elements.
Since

2N
(mod
3),
we
obtain
Ninto
which
2an
0multisets
(mod
3).
By
lemma
ultisets
of
equal
sum.
pproach
IOI,
and
thus
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
fbe
(1)
fAssign
(2).
Fto
(N
)two
will
have
equal
2to
elements.
Since
N

2)
(mod
3),
we
obtain
N
iswhich
2obtain

0F
(mo
Theorem
2.
If
N
is
divisible
by
three,
then
(N
)
3,
F
(N
)
can
be
partitioned
two
of
equal
sum,
f
(1)

f
(2).
(N
)
have
N

2
elements.
Since
N

2
(mod
3),
we
N
al
to
the
sum
of
all
elements
in
B
in
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
implies
theorem.
our
will
impl

2
),
...f
(b)}
some
a
<
b.
can
partition
F
into

mod
3).
F
(N
)
can
partitioned
into
multisets
of
equal
sum.
Proof.
f
(1)
to
A
and
f
(2)
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
ma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
sum.
Therefore,
the

because
F
(N
)
is
even
while
f
(1)
is
ven.
However,
sum
of
all
in
F
(N
)Since
F
(N
)B
+
fno
(1),
which
is
odd
Assign
fno
to
A
and
to
Since
fby
(1)
=
f
(2),
weF
are
Proof.
Assign
f)a2elements
(1)
A0with
and
fis
(2)
to
Since
(1)
=
(2),
we
are
now
trying
to
partition
F
(N
)no
and
is
an
there
edge
isF
connecting
an
connecting
A
and
B.
A
Since
and
A,
/(1)
VF
A,

B
S,

/
we
V
have

S,
A,
we
B

S.
A,
As
Bnotwo
A

S.
and
As
B
A
are
connected
B
are
cs
Proof.
Assign
f(N
(1)
to
A
and
f
(2)
to
B.
Since
ffway
(1)
ffpartition
(2),
we
are
now
trying
to
(N
all
elements
in
Fthe
(N
)problem
=
(N
+
(1),
odd
because
(N
)=
is
even
while
fB.
(1)
is
odd.
Therefore,
there
is(N
Proof.
Assign
f23k),
to
and
(mod
to
. 3),
Since
,(2)
we
are
now
trying
to
because
Fthere
(N
iseven
even
while
fisedge
(1)
is
odd.
Therefore,
there
to
F
(N
).
because
F
(N
)Proof.
even
while
f
(1)
is
odd.
Therefore,
there
is
way
to
partition
F
kcause
any
consecutive
subsequence
length
multiples
of
three,
which
will
F
=
Proof.
Assign
f3,
to
A
and
ftoF
(2)
to
B.
fB.
(1)
=
f(N
(2),
we
are
now
trying
to
partition
Fpartition
(N
=
F
(N
))n
f)is
(1)

f(1)
(2).
F
)isof
will
N

2=
elements.
Since
N
2whether
(mod
3),
we
obtain
N

2theorem.
0)and
(mod
3).
bwhich

2sum,
bwe

ahave

2denote
blem.
PARTITION
NP-hard
by
reduction
from
SUBSET is
}.
B
=
{f
(a
+
+

k
F
(N
)and
while
f
(1)
odd.
Therefore,
there
is
way
to
partition
F
(N
).
b

2
Theorem
3.
If
N
1
F
)
cannot
be
partitioned
into
multisets
of
equal
two
have
Therefore,
solving
this
problem
is
reduced
to
checking
N

1
(mod
3).
We
can
solve
this
can
be
partitioned
into
multisets
of
equal
which
implies
our
theorem.
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
F
(N
)

eed
to
use
this
approach.
We
must
nd
a
special
constraint
in
the
problem
such
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
k
F
)San
can
be
partitioned
into
two
multisets
equal
sum,
which
implies
our
theo
are
(a
+
Aby
{f
(a
0note

}+

{f
+
1f(N
+
3k),
0This

}contradiction.
3felements.
A
{f
(a
+
3k),
0we

}<
(N
{f
(a
+
1
3k),

}
3k),
B.
Since
(1)
=
(2),
we
now
trying
tofNote
partition
(N
)(1),
F
)

F
(N
)an
=
F
(N
)f)partition

felements.
fpartition
(2).
F0F
(N
)
will
have
N

2a1
elements.
Since
N

22
(mod
3),
we
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
which
isk22Ifis
odd
Proof.
Suppose
F
)will
=be
F
(N
)N

(1).
contains
elements.
Since

12whether
(mod
3),
we
there
f
)ven.
is=
odd.
Therefore,
is
no
way
to
F
).
(2).
F
)equal
will
have
N
2of
elements.
N
23).
(mod
3),
f=
(1)

(2).
F
(N
will
have
N(1)

2that
Since
N
(mod
3),
we
obtain
N(mod
then

(mod
3).
by
an
edge,
an
edge,
we
that
that
S3,
not
is
INDEPENDENT-SET.
not
an
INDEPENDENT-SET.
This
contradiction.
is
Therefore
Therefore

Slemm
is
Vowa1
partition
.
into
will
reduced
Since
fthe
(1)

ff(N
(2).
F
(N
))kis
will
have
N
2(N
elements.
Since
N

(mod
3),
obtain

00V
(mod
3).
no
way
to
partition
Fknote
(N
).
1),
f(2)
(a
2),
...f
(b)}
some
a
b.
We
can
F
now
trying
to
partition
F
(N
=
F
(N
Proof.
N
is
divisible
by
three,
F
(N
)N
is
a(N
b2(N

2)3),
bto
a=

2(N
fHowever,
f+
fto
(2).
F
)fafor
have

2
Since

2in
(mod
3),
we
obtain
N

2Since

0N
By
whether
Therefore,
solving
this
problem
to
checking

3,
F
(N
)
can
partitioned
into
two
multisets
of
sum,
implies
our
theorem.
s+
unlikely
to
be
able
to
nd
that
nds
A
and
B
an
Therefore,
solving
this
problem
is
reduced
checking
N

1a
(mod
3).
We
can
solve
this
3(1)
3elements.
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N
)we
1sum.
(mod
3).
We
can
solve
this
3more
3have
and
f(1)
to
B.
Since
(1)
=
falgorithm
(2),
we
are
now
trying
toN
partition
F
(N
)which
=
Fequal
(N
We
will
provide
examples
of
special
cases
in
the
following
section.
lements.
Since
N

(mod
we
obtain
N

0
(mod
3).
By
lemma
he
problem
be
solvable
in
polynomial
time.
We
can
check
whether
an
additional
Theorem
4.
If
N

2
(mod
3).
F

Theorem
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
oks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NP-hard
by
reduction
from
SUBSETTheorem
4.
If
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of

f
(a
+
3k),
0

{f
(a
+
1
+
3k),
0

}
Theorem
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
ba2
heorem
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Proof.
Suppose
(N
)
=
F
(N
)

f
(1).
Note
that
F
(N
)
contains
N

1
elements.
Sin
ements.
Since
N

2
(mod
3),
we
obtain
N

0
(mod
3).
lemma
(mod
3).
By
lemma
3,
F
can
be
partitioned
into
sum,
which
implies
is
odd.
Therefore,
there
is
no
way
to
partition
(N
).
haveN

0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
,
we
obtain
.
By
lemma
3,

can
be
parti
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
imp
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
VERTEX-COVER.
VERTEX-COVER.
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
bWe

2provide
fore,
solving
this
problem
is sum,
reduced
to2two
checking
whether
N

13the
(mod
3).
We
can
solve
this
in
O(1).
bthe

we
obtain
N

2
0 provide
(mod
3).
Byas
lemma
Therefore,
this
problem
is
checking
whether
N
(mod
We
can solv
A
and
BF
have
the
same
for
every
0we

kdened

can
be
partitioned
into
two
multisets
sum
3,
(N
)We
can
be
partitioned
into
multisets
ofsum.
equal
sum,
which
implies
our
theorem.
will
more
examples
of
special
cases
in1 the
following
section.
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N3).of
1 equal
(mod
3).o
3 into
ned
in
awill
very
special
way,
in
that
F
is
using
the
will
more
examples
of
special
cases
in
following
section.
We
will
more
examples
of
special
cases
the
following
section.
WAN
3nd
have
N
2abe
Since
N,3k),
20asolving
(mod
3),
obtain
Nreduced
2inchecking

0to
(mod
3).
By
lemma
multisets
of
equal
sum,
which
implies
our
theorem.
F=
(N
) for
can
partitioned
two
multisets
equal
bsense

2(mod
bcan

abe
N
2
}.
B
=
{f
(a
+
+

kaof}.

nto
two
multisets
of
equal
sum.
refore,
large
value
oftwo
N
it
isis
unlikely
toof
be
able
to
an
algorithm
that
nds
AF
and
B
in
anmultisets
B
{f
(a
+
2elements.
+
3k),
0provide

k2F

solving
into
Therefore,
this
problem
is
reduced
to
whether
1
(mod
3).
We
can
solve
this
haveN
1

0
3).
By
lemma
3,
F
(N
)
partitioned
two
of
equ
tioned
into
multisets
equal
sum,
which
implies
our
theorem.
multisets
of
equal
sum,
which
implies
our
theorem.
sum
of
all
elements
in
(N
)
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
(N
)
+
f
(1),
which
is
odd

bspecial
a kf
2 3to
Atheorem.
=examples
{f
(arecurrence
+We
0
cases
}following
{f
(a
+
1and
3k),
0 are

kB.
Since
}section.
rovide
more
of
in provide
the
section.
plies
will
provide
more
examples
of
special
cases
innow
the
following
Proof.
Assign
fF(mod
(1)
to
AF
and
to
We
will
more
examples
of
special
cases
in
the
following
section.
Proof.
Assign
fG(V,
(1)
to
A
and
f=
(2)
to
Since
fwhether
(1)
=
fof
(2),
inspect
the
formula
more
closely.
Proof.
Assign
f0(1)
to3k),
A
and
(2)
B.
Since
fspecial
(1)
=
f+
(2),
we
now
trying
to
partition
(N
)We
=
F(N
(N)solve
)f(2)

Proof.
Assign
fproblem
(1)
to
A
fwe
(2)
to
fF
(1)
f1INDEPENDENT-SET
(2),
we
are
trying
to
oof.
Assign
(1)
to
A
and
fsolving
(2)
to
B.
Since
f3(a
(1)
=
fcases
(2),
are
trying
to
partition
F
(N
).the
=now
ned
into
two
ofTherefore,
equal
sum,
which
implies
our
theorem.
solving
this
isway,
reduced
to
checking
whether
N

1B.
3).
We
can
solv
F
(NHowever,
)our
can
befmultisets
partitioned
into
two
multisets
ofof
equal
sum.
}.
fould
(a
+
2
+
3k),

Therefore,
solving
this
problem
is
reduced
to
checking
N
p
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N

(mod
3).
can
solve
thi
Lemma
2.
Lemma
2.
If
S

V
If
is
S
a

VERTEX-COVER
V
is
a
VERTEX-COVER
of
graph
of
G(V,
graph
E),
then
E),
V

then
S
is
V
an

S
is
an
INDEPENDENT-SE
the
Therefore,
solving
this
problem
is
to
checking
whether
N

1
(mod
3).
We
can
3
3
reduced
this
ay.
sequence
is
dened
in
a
very
in
the
sense
that
dened
using
this
Theorem
3.
If
N

1
(mod
3),
F
(N
)
cannot
be
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N

1
(mod
3).
We
can
solve
this
in
O(1).
f
(a
+
3k)
+
f
+
1
+
3k)
=
f
(a
+
2
+
3k)
We
will
provide
more
examples
special
in
the
following
section.
Therefore,
this
problem
is
reduced
to
checking
whether
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N

because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
(mod
Fof

3
educed
to
checking
whether
N

1
3).
We
can
solve
this
in
O(1).
f
(1)

f
(2).
F
(N
)
will
have
N

2
e
2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
(N
)

4
Some
example
special
cases

),
we
are
now
trying
to
partition
F
(N
)
=
F
(N
)

ba2
f
(1)

f
(2).
F
(N
)
will
have

2
elements.
Since
N

2
(m
foned
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N

0
(mod
3).
By
lemma
ba2
f
(1)

f
(2).
(N
)
will
have
N

2
elements.
Since
N

(mod
3),
we
obtain
N

2
1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N

0
(mod
3).
By
lemma
educed
to
checking
whether
N

1
(mod
3).
We
can
solve
this
in
O(1).
B
will
have
the
same
sum,
as
for
every
0

We
will
more
examples
ofin
special
cases
insection.
the
following
section.
the
same
sum,
as
for
every
0provide
kcan

We
will
provide
more
examples
of
special
cases
in the
following
section.
We
provide
more
examples
of
special
cases
in the
the
following
section.
graph
G(V,
graph
E)
G(V,
E)
We
will
provide
examples
of
special
cases
in
following
section.
inspect
recurrence.
Therefore,
we0more
should
the
recurrence
formula
more
closely.
with
length
multiples
of
three
be
into
two
multisets
sF
1
(mod
3).
We
can
solve
this
in
O(1).
3
We
can
solve
this
in
.
We
will
provide
more
examples
of
special
cases
the
following
3partitioned
odd.
because
F
(N
)
is
even
while
f
(1)
is
Therefore,
there
is
no
way
to
partition
F
(N
).

4
Some
example
of
specia
4
Some
example
of
special
cases
4
Some
example
of
special
cases

}.
B
=
{f
(a
+
2
+
3k),

problem
is
reduced
to
checking
whether
N

1
(mod
3).
We
can
solve
this
in
O(1).

)ial
B.)3),
Since
fpartitioned
(1)
=
(2),
we
are
now
trying
to
partition
Fwhich
(N
)Proof.
=
Fpartitioned
(N
)our
of
ial
cases
in
the
following
3,theorem.
Finto
)two
be(N
partitioned
into
two

2FTheorem
elements.
Since
2section.
(mod
3),(N
we
obtain
N

23,sum,
sum,
(mod
3).
By
lemma
(mod
wethe
obtain
N

03,ba2
(mod
3).
lemma
F0 (N
)into
be
equal
sum,
w
3,
(N
)can
can
be
partitioned
into
two
of
equal
implies
F
)(N
can
be
partitioned
into
two
multisets
equal
sum,
which
our
theore
Suppose
F(N
(N
)can
=multisets
F
) implies
of
f (1).
Note
tha
3can
ame
sum,
as
for
every
0f
k

Fto
(N
be
into
two
multisets
of
equal
which
implies
our
theorem.
cases
in
following
4.
If
NN
2section.
(mod
3).
Fmultisets
)By
be
two
multisets
of
equal
sum.
3 common
We
will
provide
more
examples
ofpartitioned
special
cases
in
the
following
section.
4
Some
example
of
special
cases
4theorem.
Some
example
of
special
cases
4three
Some
example
of
special
We
will
look
atfwhich
some
examples
of=
special
cases
that
may
occur
inistwo
competitive
programming
p
mples
ofimplies
special
cases
in
the
following
section.
Irvin
GUNAWAN
case
,onathan
2 elements.
Since
N

2proof
(mod
3),
we
obtain
N

0
(mod
3).
By
lemma
Any
consecutive
subsequence
of
F
with
length
multiples
of
can
be
partitioned
into
multisets
3k)
+
f
(a
+
1
+
3k)
f
(a
+
2
+
3k)
two
multisets
offour
equal
sum,
implies
our
Proof.
Proof.
The
proof
is
actually
is
similar
actually
to
similar
the
previous
to
the
lemma.
previous
Let
lemma.
us
assume
Let
us
that
assume
V

S
that
not
V

a
S
INDEPENDENT-SET
is
not
a
INDEPEND
(a
+The
3k)
+
(a
+
1
+
3k)
=
f
(a
2
+
3k)
which
theorem.
haveN
partitioned
1special
occur
0occur
(mod
3).
By
lemma
3,of
Fequal
(Noccur
) sum
can
Theorem
4.

2checking
(mod
3).
F (Ncases
)common
can
be
into
two
multisets
4Ifk NWe
Some
example
of
cases
ba2
will
look
at
some
examples
of
special
cases
that
may
We
will
look
at
some
common
examples
of
special
that
may
in
competitive
programming
p
We
will
look
at
some
common
examples
of
special
cases
that
may
in
competitive
programming
p
Therefore,
solving
this
problem
is
Therefore,
solving
this
problem
is
reduced
to
checking
whet
Therefore,
solving
this
problem
is
reduced
to
whether
N

1
(mod
3).
We
can
solve
this
in
O(1).
will
have
the
same
sum,
as
for
every
0

Therefore,
solving
this
problem
is
reduced
to
checking
whether
N

1
(mod
3).
W
this
problem
is
reduced
toV
checking
14
(mod
3). We
can
this
inB.
solve
3
flength
(asolving
+there
3k)
+are
fto
(a
+of
1vertices
+
3k)
=
(a
24
+BS
3k)
two
multisets
of
equal
sum,
which
implies
our
theorem.
Assign
f (1)
A
and
ftwo
(2)
tofB
B.
Since
fdenote
(1)
= Sfby(2),
we
are
now
trying
to
partition
Feven.
(N
)O(1).
=
Fspeci
)
m.
Therefore,
Therefore,
there
two
are
A,
vertices
+
A,

and
V whether

there
and
is
an
there
edge
connecting
anSome
edge
connecting
Ain
and
B.A
Since
and
A,
B
Since
(N
VA,
BS
Some
example
of
special
cases
example
of
4
Some
example
of
special
cases
f Therefore,
FProof.
with
multiples
three,
which
we
will
FinN
=
sum
ofis
all
elements
F
(N
)competitive
is
However,
4ofWe
Some
example
of
special
cases
ook
at
some
common
examples
special
cases
that
may
occur
competitive
programming
problems.
will
look
atN
some
common
examples
ofprovide
special
cases
that
may
occur
in
will
look
at
some
common
examples
of
special
cases
that
may
occur
in programm
competit
We
will
provide
more
examples
ofparti
speth
m
is
reduced
to(mod
checking
whether

1cases
(mod
3).
We
can
solve
this
in3),
O(1).
me
example
of
special
cases
hether
N

1
3).
We
can
solve
this
in
O(1).
We
will
more
examples
of
special
cases
in
the
following
We
will
provide
more
examples
of
special
cases
in
the
following
section.
We
We
will
provide
more
examples
of
special
cases
in
the
following
section.

e
will
provide
more
examples
of
special
in
the
following
section.
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to

f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
we
obtain
N

0
(mod
3).
By
lemma
me
cases
wecases
have
A,
we
BSome
have

/of
S.
A,
B

/+some
S.
and
As
A
and
connected
byof
an
edge,
by+Planar
an
we
edge,
note
that
weF
note
S occur
is
that
aS VERTEX-COVER.
iswhile
not fa(1)
VERTEX-COVER.
ispa
4.1
graphs
aial
< example
b.
We
can
partition
Fspecial
into
We
will
look
common
special
cases
that
may
in
competitive
programming
because
(N
)will
isnot
even
odd. This
Therefo
Irvin
GUNAWAN
Example
ofB
Special
Cases
fAs
(aatA
3k)
+
fare
(a
+ length
1Bexamples
+are
3k)connected
=
fcan
(a
+solve
2of
3k)
khan
any
consecutive
subsequence
of
Fsome
with
multiples
three,
we
denote
bycompetitive
F =isthat
mNAWAN
is4
reduced
to4.
checking
whether
N

1 F(mod
3).
We
this
inwhich
O(1).
Some
example
of
special
cases
special
in
the
following
section.
ng
section.
cases
4.1
Planar
graphs
4.1
Planar
graphs
We
will
look
at
common
examples
of
special
cases
that
may
occur
in
programm
4.1
Planar
graphs
We
will
look
at
some
common
examples
of
special
cases
may
occur
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
f
(1)

f
(2).
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N

3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
contradiction.
contradiction.
Therefore
Therefore
V

S
is
V
an

INDEPENDENT-SET.
S
is
an
INDEPENDENT-SET.
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
AN
es
ofaspecial
special
cases
that
maysome
occur
in
competitive
programming
problems.
+
1),
f(a
...f
(b)}
for
a in
< competitive
b.that
We
F ainto
b
2+ 2),
bPlanar
acan
be
2partition
Planar
graph
a (N
graph
drawn
on
at
surface
without
having
twographs
edges
o
special
cases
in
thethat
following
4.1
graphs
4.1
Planar
4.1
Planar
es
of
cases
may
programming
problems.
Theorem
4.
Ifgraphs
N
2which
(mod
3). Fcrossing
(N
) theorem.
caneach
be pa
3,isoccur
Fsection.
) can
be can
partitioned
into
two
multisets
of
equal
sum,
implies
our
r
in
competitive
programming
problems.
}

{f
(a
+
1
+
3k),
0

}
Planar
graph
is
aof
graph
that
can
be
drawn
on
ais can
at
surface
without
havi
4
Som
Planar
graph
is
aaproblem
graph
that
can
be
drawn
on
aaspecial
at
surface
without
having
two
edges
crossing
each
ot
4
Some
example
of
Planar
graph
is
graph
that
can
be
drawn
on
at
surface
without
having
two
edges
crossing
each
ot
4.1
Planar
graphs
4
Some
example
of
special
cases
mmon
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
4
Some
example
of
special
cases
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
will
prov
Therefore,
solving
this
is
reduced
to
checking
whether
N

1
(mod
3).
We
solve
this
in
O(1).
3GUNAWAN
3
4
Some
example
of
cases
Theorem
1.
1.
If
S

V
If
is
S
a

MAX-INDEPENDENT-SET
V
is
a
MAX-INDEPENDENT-SET
graph
G(V,
of
graph
E),
G(V,
then
E),
V

then
S
V
a
MIN-VERTEX-COVER

S
is
a
MIN-VERTE
rvinTheorem
We will look at someb
common
examples of special
casesPlanar
thatb may
occur
in4.1
competitive
a at

2graph
graphs
acrossing

2at
4.1
graphs
Planar
graphs
4.1
is
aAa
graph
that
can
be
drawn
onamany
agraph
without
having
two
each
Planar
graph
is
that
can
be
on
aProof.
surface
without
having
two
crossing
et
al.
2001).
There
are
many
graph
which
easy
solve
ifprov
thefc
Planar
graph
graph
that
can
be
drawn
on
aproblems
surface
without
having
two
edg
Some
example
cases
et
al.
2001).
There
are
graph
problems
which
are
easy
to
solve
the
graph
planar.
We
will
et
al.
2001).
There
are
problems
which
are
easy
to
solve
the
isisare
planar.
We
will
prov
faphspecial
cases
4.1
Planar
graphs
b

2of
Assign
fifif}(1)
tograph
A other
and
f(West
(2)
toto
B.
Since
=
{f
(a
+more
3k),
0of

kspecial
E).
}surface
is
{fathis
(a
1drawn
+
3k),
0Planar

kat
edges
Therefore,
solving
problem
is
reduced
to
checking
whether
N

1edges
(mod
3).
We
examples.
We
will
provide
examples
of many
special
cases
in +
the
following
section.
of
the
graph
the
G(V,
graph
E).
G(V,
4.1
Planar
graphs
programming
problems.
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
otm
}.
k

3
3
4.1
Planar
graphs
We
will
look
at
some
common
examp
We
will
look
at
some
common
examples
of
special
cases
that
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.

1).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
will
provide
several
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
wi
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitiv
ome
example
of
special
cases
examples.
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifcrossing
the
graph
ishav
poeo
examples.
e will look
some
common
examples
of
special
cases
that
may
occur
in
competitive
problems.
3 at examples.
fasurface
(1)
surface
fcan
(2).
Fwithout
(N
)programming
will
have
Nsurface

2crossing
elements.
Sin
We
will
provide
more
examples
of
special
cases
in
the
following
section.
Planar
graph
is
a
graph
that
can
be
drawn
on
at
having
two
edges
crossing
Planar
graph
is
a
graph
that
be
drawn
on
a
at
without
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
each
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
without
having
two
edges
each
4.1
Planar
graphs
b

2
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(Wes
etsurface
al.cases
2001).
There
are
many
graph
problems
which
are
easy
toThe
solve
ifthat
the
graph
is planar.
We
will
prov
amples
ofa =
special
that
may
occur
inproblems.
competitive
programming
problems.
mayProof.
occur
in
competitive
programming
only
rawn
on
at
without
having
two
edges
crossing
each
other
(West
examples.
Proof.
We
know
We
that
know
V

that
S
is
V
a

vertex
S
is
a
cover
vertex
by
cover
lemma
by
1.
lemma
The
1.
thing
only
thing
remains
that
for
remains
us
to
for
prove
us
to
is
it
p
examples.
}.
B
{f
(a
+
2
+
3k),
0

3,
F
(N
)
can
be
partitioned
into
two
multisets
of
ba2
awn
on
a
at
surface
without
having
two
each
other
(West
et
al.are
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifgraph
the graph
is planar.
Weifpro
wi
et al.crossing
2001).
There
are
many
problems
which
easy
to
th
etcrossing
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
theplanar.
graph
planar.
Wesolve
will
pro
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifif the
isisare
planar.
We
will
4.1.1
Number
of
edges
ving
two
edges
each
other
(West
3edges
ry
0 can

kal.
et
2001).
There
many
graph
problems
which
are
easy
to
solve
ifgraph
the
is
We
will
provide
examples.
mples
of
special
cases
may
occur
competitive
programming
problems.
3 Suppose
hat
be
drawn
on
atothat
at
surface
without
two
edges
crossing
each
other
(West
oblems
which
are
easy
solve
ifSthe
the
graph
isishaving
planar.
We
will
provide
several
V
4
is
VSome
not
inS
minimum
not
minimum
vertex
cover.
vertex
Then,
cover.
there
Then,
isgraph
another
there
is vertex
another
cover
vertex
V

cover
S severa
where
V
minimality.
minimality.
Suppose
example
of
special
cases
4.1.1
Number
of
edges
4.1
Planar
g
4.1.
Planar
Graphs
4.1.1
Number
of
edges
4.1
Planar
graphs
4.1.1
Number
of
edges
4.1
Planar
graphs
blems
which
are
easy
to
solve
if
graph
is
planar.
We
will
provide
several
examples.
examples.
examples.
examples.
4.1
Planar
graphs
he graph
is planar.
We
provide
several
examples.
ba2
will
graph
edges
provide
solving
Therefore,
this
problem
is cases
reduced
to ca
any
graph
are
easy
to
solve
the
is
planar.
We
will
several
InPlanar
simple
general
graph,
the
of
canBy
be
up
order
with
respect
the
4|Sedges
Some
example
ofindependent
special
ill
sum,
for
0
kimplies
ifnumber
the
|V
<
|V

S
which
<as
|V
which

S|,
implies
which
that
|S
|3 that
> of
|S|.
By
|>
lemma
|S|.
2,lemma
S
isto
an
2,a independent
Squadratic
isNumber
an
set.
Therefore,
set.
Therefore,
S to
is not
4.1.1
Number
4.1.1
Number
of
edges
4.1
4.1.1
of
edges
graphs
+ have
f |V
(a +
1Sproblems
+|same
3k)
=
f|S|,
(a
+
2graphs
+every
3k)
Planar
graph
iseach
awith
graph
that
can
bein
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadrat
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
2
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
respect
to
the
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(West
4.1.1
Number
of
edges
Planar
graph
is
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
We
will
provide
more
examples
of
special
cases
anar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
other
(West
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
Ednn
maximum
independent
independent
set. This set.
is a This
contradiction.
is a contradiction.
Therefore
Therefore
V S is Vthe
minimum
S is the minimum
vertex cover.
vertex cover. wi
4.1 maximum
Planar
graphs
2
2
4.1.1
Number
of
edges
2
4.1.1
Number
of
edges
4.1.1
Number
of
edges
4.1.1
Number
of
edges
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
number
of
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
etis
al.
2001).
There
are
many
graph
pr
be
drawn
on
avertices
at
surface
without
having
two
edges
each
other
(West
Planar
graph
is
aet
graph
that
can
be
drawn
on
a2Therefore,
flat
surface
without
having
two
edges
vertices
(i.e.
O(V
)).
isgraph
not
case
for
planar
graph.
In
aeasy
planar
In
simple
graph,
the
number
of
edges
can
be
up
to
aO(V
quadratic
order
wi
without
having
two
edges
each
other
(West
fV(acrossing
+3graph
3k)
+
fThis
(a
+is
1general
+
3k)
=
fcrossing
(aal.
+
+
3k)
eteasy
2001).
There
are
graph
problems
are
to
(i.e.
O(V
)).
not
the
case
for
planar
In
athe
planar
graph,
we
may
show
that
E
et
2001).
There
are
many
problems
which
are
to
solve
ifgraph.
the
graph
planar.
We
will
provide
several
vertices
(i.e.
O(V
)).
This
issome
not
the
case
for
planar
graph.
Inmany
ais
planar
graph,
we
may
show
that
E
4.1.1
Number
of
edges
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifwhich
graph
is plan
We
will
look
at
common
examples
of
special
cases
that
may
occur
in).the
competitive
pr
al.al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifThis
the
planar.
We
will
provide
several
holds
for

by
using
the
Eulers
formula.
number
of
edges
is
Naturally,
any
4.1.1
Number
of
edges
simple
general
graph,
the
number
edges
can
be
upthe
tograph.
a quadratic
order
with
respect
to
the
n
2 Number
2planar
2 of
4.1.1
of
edges
i.e.
O(VifFrom
)).which
This
is
not
the
case
for
graph.
In
a
planar
graph,
we
may
show
that
E

3V

6
be
drawn
on
aIn
at
surface
without
having
two
edges
crossing
each
other
(West
crossing
each
other
(West
etal.,
2001).
There
are
many
graph
problems
which
are
easy
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
In
a
planar
graph,
we
may
show
th
examples.
h solve
problems
are
easy
to
solve
if
the
graph
is
planar.
We
will
provide
several
the
From
above
the
theorem,
above
theorem,
we
conclude
we
conclude
that
a
MIN-VERTEX-COVER
that
a
MIN-VERTEX-COVER
can
be
easily
can
be
constructed
easily
constructed
if
we
have
if
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
number
of
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
oamples.
the
graph
is
planar.
We
will
provide
several
examples.
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
examples.
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
examples.
that
has
O(E)
in
running
time
can
be
changed
into
O(V
).In
shortest
path
in
goaw
In(i.e.
simple
general
graph,
the
number
of up
edges
can
up
to
aofquadratic
order
with
to
2its
In
simple
graph,
the
number
edges
can
be
up
toarespect
ageneral
quadra
In
simple
general
graph,
the
number
ofgeneral
edges
can
be
upbeto
to
aaquadratic
quadratic
order
with
respect
to the
the
In
simple
general
graph,
the
number
of
edges
can
be
up
aComputing
order
with
respect
to
4.1.1
Number
of
edges
4.1
Planar
graphs
In
simple
general
graph,
the
number
of
edges
can
be
to
a
quadratic
order
with
respect
to
the
number
vertices
O(V
)).
This
is
not
the
case
for
planar
graph.
planar
graph,
we
may
show
that
E
4number
Some
exam
to
solve
graph
is
planar.
We
provide
several
examples.

3 by can
using
Eulers
formula.
Therefore,
the
number
ofits
is
O(V
).
Naturally,
any
algorithm
ofproblems
edges
can
bethe
up
toif
afor
quadratic
order
with
respect
tothe
the
number
of
hV
which
are
easy
to
solve
the
graph
is3will
planar.
We
will
provide
several
holds
V

3ifrunning
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
O(V
Naturall
MAX-INDEPENDENT-SET.
MAX-INDEPENDENT-SET.
that
has
O(E)
in
running
be
changed
into
O(V
).
Computin
holds
Vis

by
using
Eulers
formula.
Therefore,
theplanar
is O(
2path
2for
that
has
O(E)
in
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aedges
gr
2edges
that
has
O(E)
in its
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
inshow
a).general
general
gE
22O(V
of
edges
be
up
to
athe
quadratic
order
with
respect
to
the
number
of
vin
GUNAWAN
Bellman-Ford
takes
O(V
E)
(Halim
&
Halim
2013),
but
only
takes
O(V
)isgraph.
in
aof
planar
graph
vertices
(i.e.
)).
This
is
not
the
case
for
planar
graph.
In
awe
planar
we
may
t
2
vertices
(i.e.
O(V
)).
This
istime
not
the
case
for
plana
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
Incan
a planar
planar
graph,
we
may
show
that
vertices
(i.e.
O(V
)).
This
not
the
case
for
planar
graph.
In
ait
graph,
we
may
that
4.1
Planar
graphs
atic
order
with
respect
to
the
number
ofinto
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
ato
planar
graph,
may
show
that
EIninashow
3V
E
holds
for
V

3algorithm
byup
using
the
Eulers
formula.
Therefore,
the
number
of
edges
isgraph,
O(V
).
Naturally,
any
2
2
thePlanar
number
of
edges
can
be
to
a
quadratic
order
with
respect
the
number
of
O(E)
in
its
running
time
can
be
changed
O(V
).
Computing
shortest
path
in
a
general
graph
using
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

6
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(West
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
a
gen
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
tp
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
4.1.1
Number
of
4.1.1
Number
of
edges
4.1.1
Number
of
edges
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

6
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
holds
for
V

3using
byusing
thecan
Eulers
formula.
Therefore,
theatnumber
of).Therefore,
edges
is ).
O(V
Naturall
holds
for
V changed

3 Therefore,
by
using
the
Eulers
formula.
the
number
of
holds
for
in
3the
by
the
Eulers
formula.
Therefore,
the
number
of edges
edges
is O(V
O(V
).
Naturally,
an
holds
for
VV

3E
by
using
the
Eulers
formula.
the
number
of
is
Naturally,
any
4.1.1
Number
of
edges
ar graph,
we
may
show
that
graph
3V
6isformula.
holds
for that
Vbeginning

3the
byO(E)
using
Eulers
Therefore,
the
number
of
edges
is
Naturally,
any
algorithm
has
its
running
be
into
O(V
Computing
shortest
path
in
ain).
general
gr
We
will
look
some
common
examples
of
special
2).
2two
2i
4.1.1.
Number
of
Edges
his
is
not
the
case
for
planar
graph.
InHalim
aiswe
planar
graph,
we
may
show
that
Ein
asurface
3V
itO(V
62013),
Planar
atime
graph
that
can
be
drawn
on
athe
at
without
having
edges
cro
Ford
algorithm
takes
O(V
E)
(Halim
&
2013),
but
it
only
takes
O(V
)
planar
graph.
Counting
ormula.
Therefore,
number
of
edges
O(V
).
Naturally,
any
algorithm
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
graph
is
planar.
We
will
provide
several
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
only
takes
O(V
)
a
planar
In
the
In
the
beginning
of
this
section,
of
this
section,
assume
we
we
assume
know
we
that
know
MIN-VERTEX-COVER
MIN-VERTEX-COVER
is
a
NP-hard
is
a
NP-hard
problem.
prob
It
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
but
it
only
takes
O(V
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
4.1.1
Number
of
edges
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
of
edges
ormula.
Therefore,
the
number
ofalgorithm
edges
O(V
).
Naturally,
any
algorithm
planar
Therefore,
ifisrunning
the
problem
requires
usgeneral
to
compute
the
number
ofO(V
connected
components
that
has
O(E)
in
its
time
can
be
changed
into
O(V
).with
Computing
shortest
path
in
ausin
gen
that
has
O(E)
its
running
time
be
changed
into
O(V
).order
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
inthe
general
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aabeComputi
general
g
fner
edges
is
O(V
).components
Naturally,
any
In
simple
general
graph,
number
that
has
O(E)
ingraph.
its
running
time
be
changed
into
O(V
).This
Computing
shortest
path
into
a2athe
general
Bellman-Ford
algorithm
takes
E)
(Halim
&
Halim
2013),
but
itcan
takes
)the
inin
anumber
planar
graph.
In
simple
graph,
the
number
of
edges
can
up
towe
simple
general
graph,
the
number
ofcan
edges
can
be
up
toin
abe
quadratic
order
respect
ofnumb
Ingraph,
simple
general
graph,
the
number
of
edges
can
be
up
to
ato
with
In
simple
general
the
number
of
edges
can
up
to
quadratic
order
respect
simple
general
graph,
the
number
of
edges
can
be
up
to
a).
quadratic
order
with
the
number
of
the
Eulers
Therefore,
the
edges
is
O(V
Naturally,
any
algorithm
et
al.
2001).
are
many
graph
problems
are
easy
towith
ifquadratic
graph
isthe
planar.
of
connected
using
DFS
in
aO(V
general
graph
takes
O(V
+a000,
E),
but
itonly
only
)new
a2components
be
changed
into
O(V
).
Computing
shortest
path
in
arequires
general
graph
using
examples.
the
number
of
connected
components
using
DFS
in
awhich
general
graph
takes
O(V
+
E),
but
itsolutio
only
good
to formula.
know
good
as
to
many
know
NP-hard
as
many
problem
NP-hard
as
possible.
as
possible.
This
isus
necessary
is
necessary
so
that
if
so
we
that
encounter
ifthe
we
encounter
problem
agraph
new
X,
prob
planar
graph.
Therefore,
if
the
problem
requires
us
to
number
of
connected
components
using
DFS
in
arespect
general
graph
takes
O(V
+
E)ii
4.1.1
Number
of
edges
2solve
planar
graph.
Therefore,
ififThere
the
problem
to
compute
the
number
of
connected
planar
graph.
Therefore,
the
problem
requires
us
to
compute
the
number
of
connected
components
22compute
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
2
graph,
even
though
the
constraint
states
that
V

100,
E

100,
000
,
standard
DFS
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
2
2
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
2
2&
path
in
awith
general
graph
vertices
(i.e.
)).
This
isgraph.
not
the
mber
of(i.e.
edges
can
be
up
to
aonly
quadratic
order
respect
to
number
of
2the
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
Halim
but
itto
only
takes
O(V
)and
inaO(V
athus
planar
graph.
Countin
oing
a shortest
quadratic
order
respect
to
the
number
of
the
number
of
connected
components
using
DFS
in
ato
general
graph
takes
O(V
+
E),
it3V
only
takes
vertices
(i.e.
O(V
)).
This
is
not
case
for
planar
IO
2planar
vertices
O(V
)).
This
not
the
case
for
planar
graph.
In
athe
planar
graph,
we
may
show
that
E

3V

6conne
to
number
of
vertices
(i.e.
).
This
is
not
case
for
planar
graph.
In
planar
vertices
(i.e.
O(V
)).
This
is2013),
the
case
for
planar
graph.
In
a100,
planar
graph,
wealso
m
22the
rtices
O(V
)).
This
is
not
the
case
for
graph.
In
a
planar
graph,
we
may
show
that
Ebut

6100,
ning
time
can
be
changed
into
O(V
).using
Computing
shortest
path
in
aof
general
graph
using
examples.
P
aph.
Therefore,
if2013),
the
problem
requires
us
to
compute
the
number
connected
components
in
athe
planar
(Halim
&(i.e.
Halim
but
itisthe
takes
O(V
inwith
planar
graph.
Counting
planar
graph.
Therefore,
the
problem
requires
us
compute
the
number
of
connected
compon
can
use
any
can
of
use
the
any
NP-hard
of
problems
NP-hard
problems
that
we
know,
we
reduce
know,
itthe
reduce
problem
it
to
X,
problem
and
thus
X,compute
prove
that
prove
X
is
that
also
X
NP-hard
is
graph,
even
though
the
constraint
states
that

000,
E
4.1
00
2if
planar
graph.
Therefore,
ifusing
the
problem
requires
us
to
number
of
graph,
even
though
the
constraint
states
that
Vnot
100,
000,
E

100,
000
the
standard
DFS
solution
even
though
the
constraint
states
that
V

100,
000,
E

100,
000
,, V
the
standard
DFS
solution
2 graph,
Halim
&
Halim
2013),
but
it
only
takes
O(V
))Therefore,
in
aathat
planar
graph.
Counting
under
one
second
(in
competitive
programming,
we
assume
that
1number
million
operations
can
be
done
in
the
number
of
connected
components
DFS
in
aedges
general
graph
takes
O(V
+
E),
but
it
only
the
number
of
connected
components
using
DFS
in
a
general
graph
take
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
mber
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
number
of
y
takes
O(V
)
in
a
planar
graph.
Counting
holds
for
V

3
by
using
the
Eulers
f
t
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

6
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
2
In
a
planar
graph,
we
may
show
that
E

3V

6
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
of
connected
components
i
holds
for
V

3
by
using
the
formula.
Therefore,
the
n
2
graph,
we
may
show
that

holds
for

by
using
the
Eulers
holds
for
V

3
by
using
the
Eulers
formula.
the
number
of
is
O(V
).
Naturally,
any
algorithm
2 still
holds
for
V
3though
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
2 isDFS
olds
for
the
by
using
the
Eulers
formula.
Therefore,
the
of
is programming,
O(V
).
Naturally,
any
algorithm
akes
O(V
E)
& Halim
2013),
but
it+
only
takes
O(V
)number
inthat
awe
planar
graph.
Counting
en though
constraint
states
that
V even

100,
000,

100,
000
,assume
the
standard
DFS
solution
runs
using
DFS
in3(Halim
aunder
general
graph
takes
O(V
E),
but
itEthe
only
takes
O(V
) edges
in
athat
graph,
even
though
the
constraint
states
V
100,
000,

100,
000
, of
the
standard
s
under
one
second
(in
competitive
we
assume
that
1O(V
mill
graph,
constraint
states
V

100,
000,
E

100,
000
,the
the
sta
4.1.1
Number
of
edges
under
one
second
(in
competitive
programming,
that
11E
million
operations
can
be
done
in
one
second
(in
competitive
programming,
we
assume
that
million
can
be
done
in
1V
1 We
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
a
(Halim
&
Halim
2013)).
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
connected
compon
We
say
that
problem
say
that
X
problem
is
reducible
X
is
to
reducible
problem
to
Y
problem
Y
2 operations
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
num
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
of
connected
components
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
of
connected
components
Planar
graph
is
a
graph
that
can
be
drawn
on
a

the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

6
es
O(V
+
E),
but
it
only
takes
O(V
)
in
a
that
has
O(E)
in
its
running
time
can
ers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
algorithm
planar
ifthat
the
problem
requires
us
to
compute
the
number
of
connected
components
in
a plana
Therefore,
the
number
edges
is
.that
Naturally,
any
algorithm
that
has
Computing
in
its graph
number
of
edges
isTherefore,
O(V
).
Naturally,
any
algorithm
graph,
even
though
the
constraint
states
that
V

100,
000,
E

100,
000
,athe
standard
DFS
solution
has
O(E)
in
its
running
time
can
changed
into
O(V
).d
hat
has
O(E)
inits
its
running
time
can
be
changed
into
O(V
).2013)).
Computing
shortest
path
in
ageneral
general
using
has
O(E)
in its
running
time
can
be
changed
into
O(V
).
shortest
has
O(E)
in
running
can
be
changed
into
O(V
Computing
shortest
path
using
components
using
DFS
in
atime
general
graph
takes
O(V
+
E),
but
takes
O(V
)we
in
eat
second
(in
competitive
programming,
we
assume
that
1).
million
operations
can
be
done
inbe
second
m
requires
usgraph.
to
compute
the
number
of
connected
components
init
aonly
planar
under
one
second
(in
competitive
programming,
we
assume
that
1ain
million
can
bepa
4.1.1
Number
of
(Halim
&
Halim
under
one
second
(in
competitive
programming,
assume
that
1 graph
million
operati
21 operations
(Halim
&
Halim
2013)).
(Halim
&
Halim
2013)).
22 edges
m
requires
us
to
compute
the
number
of
connected
components
in
aV
planar
graph,
even
though
the
constraint
states
that

100,
000,
E
with
100,
,standard
the
standard
DFS
2There
graph,
even
though
the
constraint
states
that
Vthe

100,
000,
E 2013),

100,
graph,
even
though
the
constraint
states
that

100,
000,
E

100,
000
,000
the
standard
DFS
solutio
graph,
even
though
the
constraint
states
that
VV

100,
000,
E

100,
000
,graph
DFS
solutio
2
et
al.
2001).
are
many
graph
problems
which
2
rs
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
algorithm
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
respect
to
the
number
of
mber
of
connected
components
in
a
planar
Bellman-Ford
algorithm
takes
O(V
E)
eellman-Ford
can
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
running
time
can
be
changed
into
.
Computing
shortest
path
in
a
general
us2
graph,
even
though
the
constraint
states
that
V

100,
000,
E

100,
000
,
the
standard
DFS
solution
still
run
).
Computing
shortest
path
in
a
general
graph
using
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
b0si
2
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
Counting
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
takes
O(V
E)
& Halim
2013),
but itcomponents
only
takes O(V
) in a planar graph. Counting )in
ifHalim
the
problem
requires
compute
the
number
ofDFS
connected
in a planar
2013)).
tes
that
V
algorithm
100,
000,
Eus
to
100,
000(Halim
, the
standard
solution
still runs
runs
(Halim
&
Halim
22013)).
(Halim
& competitive
Halim
2013)).
2
2
es
that
V
100,
000,
E
100,
000
,
standard
DFS
solution
still
2
under
one
second
(in
programming,
we
assume
that
1
million
operations
can
be
2
under
one
second
(in
competitive
programming,
we
assume
that
1
mil
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
4.1.2
Maximum
Clique
examples.
In
simple
general
graph,
the
number
of
can
be
upgeneral
tomay
ait of
quadratic
order
with
can
changed
into
O(V
).
Computing
shortest
path
agraph.
general
graph
using
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
In
aedges
planar
graph,
we
show
that
E
)in
3V
res
6gdibi
000
,(Halim
the
standard
DFS
solution
runs
the
connected
components
E)
&connected
Halim
2013),
itstill
only
takes
O(V
in
aincomponents
planar
graph.
Counting
under
second
competitive
programming,
we
assume
that
1O(V
million
operations
can
be
done
1in
2
but
itbe
only
takes
O(V
)(in
in
abut
graph.
(Halim
&
Halim
2013)).
the
number
connected
components
using
DFS
in
general
he
number
of
connected
components
using
DFS
ageneral
general
graph
takes
O(V
E),
but
only
takes
O(V
aE),
the
number
ofCounting
connected
using
DFS
inproblem
anumber
graph
takes
O(V
+
eonstraint
number
ofone
components
using
DFS
inin
a4.1.2
graph
takes
++
E),
but
itMaximum
only
takes
O(V
)ain
asecon
states
that
V

100,
000,
E

100,
000
,)planar
the
standard
DFS
solution
still
runs
gramming,
we
assume
that
1planar
million
operations
can
be
done
in
1of
second
4.1.2
Clique
probl
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
2
2
gramming,
we
assume
that
1
million
operations
can
be
done
in
1
second
(Halim
&
Halim
2013)).
(Halim
&
2013)).
(Halim
&
2013)).
(Halim
&
Halim
2013)).
vertices
(i.e.
O(V
)).
isifplanar
not
the
case
forofplanar
In
planar
graph,
we
may s
E)
(Halim
&&
Halim
2013),
but
it
takes
O(V
) to
in
aHalim
graph.
Counting
holds
for
VO(V
incan
3+
by
using
the
Eulers
formula.
Therefore,
the
number
edges
is O(V
). aNaturally,
any
algorithm
llion
operations
be
in
1only
second
planar
graph.
Therefore,
the
problem
ents
using
DFS
aMaximum
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
) of
in
aset
(Halim
Halim
2013)).
graph
takes
E),
but
itproblem
only
takes
) us
inThis
aoperations
planar
graph.
Therefore,
if graph.
the
problem
us
to
compute
planar
graph.
Therefore,
ifHalim
the
problem
requires
compute
the
number
connected
components
planar
planar
graph.
Therefore,
the
problem
requires
us
to
compute
the
number
of
connect
anar
graph.
Therefore,
ifdone
the
requires
us
to
compute
the
number
of
connected
components
inin
aifasuch
planar
mpetitive
programming,
we
assume
that
1O(V
million
can
be
done
in
1
second
The
Clique
problem
requires
us
to
nd
the
maximum
of
vertices
inrequires
a graph,
that
ev
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
2
2
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).sta
N
4.1.1
nts
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
in
a
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
graph,
even
though
the
constraint
oblem
requires
us
to
compute
the
number
of
connected
components
in
a
planar
2)
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
ve
te
the
number
of
connected
components
in
a
planar
graph,
even
though
the
constraint
states
that
V

100,
000,
E
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
eve
graph,
even
though
the
constraint
states
that
V

100,
000,
E

100,
000
,
the
standard
DFS
solution
still
runs
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
ev
4.1.2
Maximum
Clique
problem
graph,
even
though
the
constraint
states
that
V

100,
000,
E

100,
000
,
the
stand
aph, even though
the in
constraint
thatconnected
V 100,by
000,
100,
, the standard
DFS
solution
still runs cliqu
vertices
the set isstates
directly
an E
edge.
By 000
reduction
from vertex
cover,
the maximum
2
2
2
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
prob
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
Clique
problem
requires
us
to
nd
maximum
set
of
vertices
inproblem
aconnected
graph,
such
that
every
of
oblem
requires
us
to
compute
the
number
of
connected
components
in
astill
planar
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)can
abe
planar
graph.
Counting
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
acompetitive
such
th
under
one
second
(in
pro
tmum
that
V
100,
E

100,
000the
,connected
the
standard
DFS
solution
runs
vertices
incompetitive
the
is
directly
by
an
edge.
By
reduction
from
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
incliqu
ave
Estates

100,
000
,
the
standard
DFS
solution
still
runs
under
one
second
(in
competitive
programming,
assume
tg
vertices
in
the
set
is
directly
connected
by
an
edge.
reduction
from
vertex
cover,
the
maximum
under
one
second
(in
competitive
programming,
we
assume
that
1In
million
operations
done
in
1we
second
vertices
in000,
the
set
is
directly
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
cliqu
4.1.2
Maximum
Clique
under
one
second
(in
programming,
we
assume
that
1pair
million
operation
nder
second
(in
competitive
programming,
we
assume
that
1By
million
operations
can
be
done
in
1graph,
second
on
general
graph
is
NP-hard.
However,
it
isset
easy
to
solve
this
problem
inin
planar
graph.
Consider
th
simple
general
graph,
the
number
of
edges
ca
.1.2 one
Maximum
Clique
problem
The
Maximum
Clique
problem
requires
uscan
to
nd
the
maximum
set
of+vertices
in
aonly
graph,
such
that
eve
2
2
Maximum
Clique
problem
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
ne.1.2
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
states
that
V

100,
000,
E

100,
000
,
the
standard
DFS
solution
still
runs
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
E),
but
it
takes
O(V
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
(Halim
&
Halim
2013)).
programming,
we
assume
that
1
million
operations
be
done
in
1
second
on
general
graph
is
NP-hard.
However,
it
is
easy
to
solve
this
problem
vertices
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
that
1
million
operations
can
be
done
in
1
second
(Halim
&
Halim
2013)).
on
general
graph
is
NP-hard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Consider
th
blem
on
general
graph
is
NP-hard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Consider
th
Halim & Halim 2013)).

is aPlanar
graph graph
that can
drawn
on can
a at
edgesNumber
crossing
each
other
(Westeach other (West
is abegraph
that
besurface
drawn without
on a athaving
surfacetwo
without
having
two
crossing
4.1.1
ofedges
edges
canSuppose
be
partitioned
two
ofedges
equal
sum..
There
many Number
graph
which
easy toProof.
solve
ifare
the
graph
is4.1.1
planar.
We
will
several
Number
ofNote
4.1.1
edges
4.1.1
Number
of
edges
et are
al.
2001).
Thereproblems
areof
many
graphare
problems
which
easy
to
if F
the
graph
isprovide
planar.
We
severa
F solve
(N
)into
=
(N
)multisets

f (1).
thatwill
F provide
(N ) contains
In simple general graph, the number
of
edges
can
be
up
to
a
quadratic
order
with4.1.1
respectN

4.1.1
Number
of
edges
examples.
haveN
number
1 03.(mod
3).
By
lemma
3,
F a(N
) can be
partitioned
int
2order
Iffor
N
1to
(mod
Fto
) graph
cannot
partitioned
int
general
graph,
the
edges
can
be3),
up
quadratic
order
with
res
ber of edges can
be up
toIna simple
quadratic
withisTheorem
respect
theof
number
of
In simple
general
graph,
the
of
can
be
up
agraph.
quadratic
order
with
to show
the
Planar
isbe
arespect
graph
that
can
vertices
(i.e.
O(V
)).number
This
notedges
the to
case
planar
In
a(Nplanar
graph,
we may

sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
eleme
2
simple
general
the
of
edges
can
In
simple
upfor
graph,
order
the
with
number
respect
of edges
to
the
ca
vertices
O(V
)).
This
is not
the be
case
graph.
In2001).
aofplanar
graph,
we
may
the case for In
planar
In
graph,
we
may
show
that
E
3Vtoplanar
ageneral
vertices
(i.e.
O(V
)).
isnumber
not
the
case
for
planar
graph.
In6quadratic
athe
planar
graph,
we
may
show
En
et
There
are
many
gra
holds
foragraph,
V2planar
(i.e.
3This
by
using
the
Eulers
formula.
Therefore,
edges
is O(V
).that
J.I.
94 graph.
Gunawan
Proof.
Suppose
F (N
) =f F
(Nis)number
al.
f (1).
Note
that
F (N
)Natur
cont
4.1.1
Number4.1.1
of
edges
because
F
(N
) is
even
while
(1)
Therefore,
there
isO(V
no
way
2
2odd.
Number
of
edges
vertices
(i.e.
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
O(V
planar
)).
graph,
This
is
we
not
may
the
show
case
that
for
pla
E
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
).
s formula. Therefore,
the
of in
edges
is O(V formula.
).
Naturally,
any algorithm
holds forthat
V number
3 by
using
the
Eulers
the number
edges is O(V
). Naturally,
examples.
has
O(E)
its running
time
canTherefore,
be
).of
Computing
in any
aN
g
haveN
1 changed
0 (modinto
3). O(V
By lemma
3, F (Nshortest
) can be2path
partitioned
holds
for
VO(E)

3edges
by
using
the
Eulers
Therefore,
holds
the
for
number

3F
by
ofbut
using
edges
the
isbe
O(V
Eulers
).O(V
Naturally,
formula.
any
Ther
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
can In
be
changed
into
).that
Computing
shortest
path
a 4.
general
graph
using
neral
graph,
the
number
of
can
be
up
toTheorem
aformula.
quadratic
order
with
respect
to
the
number
ofto
that
hasO(V
in
its
running
time
can
beinchanged
).V Computing
shortest
path
in a)number
general
gi
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
itcan
only
takes
in of
apath
plan
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
the
of
ing
Bellman-Ford
algorithm
takes
(Halim
and
Halim,
2013),
itrespect
only
takes
If
Ninto
2O(V
(mod
3).
)but
partitioned
into
two
sum
of all
elements
in F 2013),
(N
) is(N
even.
However,
the
sum
2 allgre
2 takes
2
2 6takes
2
that
has
O(E)
in
its
running
time
can
be
changed
into
that
O(V
has
).
O(E)
Computing
in
its
running
shortest
time
path
can
in
a
be
general
changed
Bellman-Ford
algorithm
O(V
E)
(Halim
&
Halim
2013),
but
it
only
O(V
)
in
a
E)
&
Halim
2013),
but
it
only
)
in
a
planar
graph.
Counting
O(V(Halim
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
on

in
a
planar
graph.
Counting
the
number
of
connected
components
using
DFS
in
vertices (i.e. O(V )). This is not the case for planar
graph.
In
planar
graph,
weis may
show
that E 3Vis
6
because
F f(N
) to
isa even
while
f (1)
odd.
Therefore,
no
2f (1) = fthere
A
(2)
toO(V
B.
Since
(2),
we
ar
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&edges
Halim
Bellman-Ford
but
algorithm
only
takes
takes
O(V
O(V
) of
inbut
E)
a planar
(Halim
graph.
&comp
Ha
the
number
of
connected
components
using
DFS
in
general
graph
O(V
E),
but
using
DFS
in
anumber
graph
takes
O(V
+ E),
but
itof
only
takes
)and
inNaturally,
afitaplanar
nts
3 by
using
Eulers
formula.
Therefore,
the
number
is
O(V
).
any
algorithm
of
connected
components
using
DFS
in(1)
a 2013),
general
graph
takes
O(V
+takes
E),
it +
only
takes
takes
,Therefore,
but
itAssign
only
takes
graph.
Therefore,
graph.
Therefore,
ifProof.
the
problem
requires
us
to
compute
the
number
connected
holds
forthe
Vthe
3general
byplanar
using
the
Eulers
formula.
the
number
of
edges
is
).
Naturally,
any
algorithm

simple
general
graph,
the
nu
f (2).
Fshortest
)requires
will
have
N

2EIn
elements.
Nit
only
2 (mod
3O
2bebut
the
number
of
connected
components
using
DFS
in
ato
the
general
number
graph
of
connected
takes
+
E),
using
DFS
takes
in
planar
graph.
Therefore,
ifrequires
the
problem
us
compute
the
number
of
connected
blem
requires
us time
to
compute
the
number
ofthe
components
in
a
) inthat
its
running
can
be
changed
into
O(V
).f (1)
Computing
path
in
ato
general
graph
using
if in
the
problem
requires
toconnected
compute
the
number
components
in
aSince
planar
graph.
Therefore,
ifus
the
problem
us
compute
the
number
of
connected
components
Theorem
4.(N
Ifof
N
2100,
(mod
3).
FO(V
(N
)components
can
partitioned
into
graph,
even
though
constraint
states
that
Vconnected
planar
000,

100,
000
, the
standard
DFS
has O(E)
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aplanar
general
graph
using
2
by the
construction
of
the
function.

2
vertices
(i.e.
O(V
)).
This
is
n
2
2
2
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
2 Eof
graph.
Therefore,
the
problem
us
planar
compute
graph.
the
Therefore,
number
if
connected
the
problem
requires
in
graph,
even
though
the
constraint
states
that
Vruns

000,
000
,components
the
standard
graph,
even
though
theif
constraint
that
the
standard
states
thattakes
Vplanar
O(V
100,
000,
E

100,
000
,2013),
the
standard
DFS
algorithm
E)
(Halim
&second
Halim
but
itrequires
only
takes
O(V
)only
in
aEassume
planar
graph.
Counting
graph,
even
though
the
constraint
states
that
Vsolution
to
100,
000,
100,
100,
000
,
the
standard
DFS
solutio
under
one
(in
competitive
programming,
we
that
million
operations
can us
be
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&states
Halim
2013),
but
itstill
takes
O(V
) 1,in
a100,
planar
graph.
Counting
by
the
construction
of
the
function.
2to for
Proof.
Assign
fassume
(1)
to
A
and
fmillion
(2)
B.
Since
fby
(1)
=
fdone
(2),
w
holds
V
a3
using
the
Eu
graph,
even
though
the
constraint
states
that
V

100,
graph,
000,
even
E

though
100,
000
the
,
constraint
the
standard
states
DFS
that
solution
V

DFS
solution
still
runs
under
one
second
(in
competitive
programming,
we
assume
that
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
ca
we
assume
that
1
million
operations
can
be
done
in
1
second
fprogramming,
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
under
one
second
(in
competitive
programming,
we
that
1
operations
can
be
in
Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multise
(Halim components
& Halim 2013)).
the number of connected
using DFSTherefore,
in a general
graph
takes
O(V +
E),
but it
takes whether
O(V ) inN
a
this
solving
problem
isthat
reduced
toonly
checking
f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mo
has
O(E)
in
its
running
tim
1million
operations
can
be
done
in
1
second
(Halim
and
Halim
2013)).
under
one
second
(in
competitive
programming,
we
under
assume
one
that
second
1
million
(in
competitive
operations
programming,
can
be
done
in
(Halim
&
Halim
2013)).
Theorem
2. Ifproblem
N&isHalim
divisible
then
F (N
)number
can
be partitioned
into
two
multisets
of
equal sum.in a planarw
Therefore,
if (Halim
the
requires
usthree,
to compute
the
of
connected
components
in
a
planar
planar graph.
Therefore,
if 2013)).
thebyproblem
requires
us
to
compute
the
number
of
connected
components
three, then
We will
more
special
the
sectio
Proof.
N is000,
divisible
Fexamples
(N ) isHalim
a2of
prex
of Fcases
within
length
multiples
of
3,byFprovide
(N
)2can
bestandard
partitioned
into
two
multisets
of following
equal
sum,
wh
Bellman-Ford
algorithm
takes
O(
(Halim
&states
Halim
2013)).
2013)).
hough
the constraint
that
V If100,
E
000
, the
DFS
solution
still
runs
graph,
even
though
the constraint
states
that
V 100,
100,
000,
E(Halim
100,&000
, the
standard
DFS
solution still runs
4.1.2
Maximum
Clique
problem
Proof. If N is4.1.2.
divisible
bycan
three,
thenProblem
F (N ) into
is a two
prex
of F with
lengthsum..
multiples
of
three. ofByconnected
lemma 3,compo
F (N )
be
partitioned
multisets
of
equal
the
number
Maximum
Clique
cond
(in competitive
weprogramming,
assume that
1wemillion
operations
can problem
be
done
1can
second
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
problem
under
one
secondprogramming,
(in competitive
assume
that
1Clique
million
operations
betodone
in 1 second
Therefore,
solving
this
isinreduced
checking
wheth
can be partitioned
into Maximum
two multisets
of equal
sum..
planar
graph.
Therefore,
ifMaxi
the
p
The
problem
requires
us to
the4maximum
set
of
vertices
in4.1.2
a graph,
such
The Maximum
CliqueClique
problem
requires
usMaximum
to find
thend
maximum
set
of
vertices
in
a graph,
4.1.2
Clique
problem
im 2013)).
Some
example
of
spe
(Halim & Halim 2013)). Theorem 3. If N 1We
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equs
will
provide
more
examples
of
special
cases
in
the
following
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
uires us to ndThe
thesuch
maximum
set
of
vertices
in
a
graph,
such
that
every
pair
of
Maximum
Clique
requires
us
maximum
set an
of edge.
vertices
in
a though
graph,
that
ev
that every
of vertices
in the
settois nd
directly
connected
by
By
reduction
graph,
even
the
vertices
in pair
the problem
set
is directly
connected
bythe
an edge.
By reduction
from
vertex
cover,such
theconstrai
maxim
TheoremThe
3. Maximum
If N 1 vertices
(mod
3),
Fthe
(Nset
) cannot
be
partitioned
into
two
multisets
of equal
sum.
Clique
problem
requires
us
to
nd
the
The
maximum
Maximum
set
of
Clique
vertices
problem
in
a
graph,
requires
such
us
to
that
nd
eve
t
in
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
m

cted by an edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
from
vertex
cover,
the
maximum
clique
problem
on
general
graph
is
NP-hard.
However,
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
cliqu
under
one
second
(in
competiti
on
general
graph
is
NP-hard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Con
examples
special N
cases
may oc
Suppose
FWe
(Nwill
)problem
= look
F (Nat
) some
f (1).common
Note that
F (N )ofcontains
1that
elements.
4.1.2 Proof.
Maximum
Clique
4.1.2
Maximum
Clique
problem
vertices
set
directly
connected
by
an
By
vertices
reduction
in
the
from
set
is
directly
cover,
the
maximum
by
an
edge.
clique
general
graph
NP-hard.
However,
isvertices
easy
solve
this
problem
in
graph.
the
edge.
N
it solve
isFinof
easy
to
solve
inthat
planar
graph.
Consider
the
colouring
a1planar
wever,
it is Suppose
easy
this
problem
in
planar
graph.
Consider
the
on to
general
graph
NP-hard.
However,
it
is
easy
to
solve
this
problem
inof
planar
graph.
Consider
th
(Halim
& connected
Halim
2013)).
a)this
graph
such
that
two
have
the
same
colour.
Note
that
ifwe
Proof.
(Ncolouring
)on
= haveN
Fisis
(N

f1problem
(1).
Note
F
(N
)adjacent
contains
1to
elements.
Since
N
two
(mod
3),

0is
(mod
3).no
By
lemma
3,it
Fproblem
(N
)
can
be vertex
partitioned
into
multisets
of
4problem
Some
example
of
st
on
general
graph
is
NP-hard.
However,
it
is
easy
to
on
solve
general
this
graph
problem
is
NP-hard.
in
planar
graph.
However,
Consider
it
is
easy
the
of
colouring
a
graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
tha

graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a

adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a
clique
of
mtwo
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
every
pair
of
of
colouring
a
graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
size problem
k insum
a graph,
vertices
insideset
the
must
coloured
with
kevery
colours.
Th
The
Maximum
requires
toofnd
ofclique
vertices
in abegraph,
such
thatTherefore,
pair
of
haveN
1 0 Clique
(mod
3).
By
lemma
3, us
Fset(N
)inthe
can
bemaximum
into
two
multisets
equal
sum.
of
all the
elements
Fthe
(N
)partitioned
is even.
However,
the
sum
ofof
all
elements
in
F
(N
) =the
F
4.1
Planar
graph
ofsize
colouring
aby
graph
such
that
no
two
adjacent
vertices
ofodd.
colouring
have
the
aFsame
graph
colour.
such
that
Note
no
that
two
ifadjacent
there
ve
a
clique
of
size
in
in
graph,
ofWe
the
vertices
the
clique
must
be
coloured
size
kthe
aset
graph,
the
set
of
the
inside
the
clique
with
kproblem
colour
be
be
with
clique
coloured
kset
colours.
Therefore,
the
entire
ertices
setvertices
isinside
directly
connected
an
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
ksetinisamust
graph,
of
the
vertices
inside
the
clique
must
coloured
with
kspecial
Therefore,
will
look
at
some
common
ofcoloured
cases
that
ma
inthe
the
directly
by
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
sum
of all
elements
in
F
(N
)connected
is
even.
However,
the
sum
of
all
elements
inbe
(Nexamples
)must
=
Fis
(N
)way
+colours.
fwith
(1),
which
isFis
odd
because
F
(N
)the
isan
even
while
fvertices
(1)
isinside
Therefore,
there
no
to
partition
(N

colours.
Therefore,
the
entire
graph
requires
at
least

colours.
By
the
four
colour
theaeven
graph,
setto
ofodd.
the itvertices
inside
the
clique
sizeproblem
k
must
intoa partition
be
graph,
coloured
set
with
of kthe
colours.
vertices
Therefore,
inside
the
graph
Planar
graph
is planar
graph
that
can
be drawn
aConsider
at
surface
without
aphbecause
is general
NP-hard.
it isthe
easy
solve
this
problem
in
graph.
Consider
the
problem
on
NP-hard.
However,
is
easy
to there
solve
in
planar
graph.
the
problem
Fsize
(NkHowever,
) in
is is
while
f (1)
is
Therefore,
isathis
no
way
F (N
).on
Jonathan
Irvin
GUNAWAN
graph
requires
at
least
kmultisets
colours.
Bysolve
therf
The
Maximum
Clique
problem
orem,
any
planar
graph
can
be
coloured
with
at
most
four
colours.
(Gonthier,
2005).
Since
Theorem
4.
If
N

2
(mod
3).
F
(N
)
can
be
partitioned
into
two
of
equal
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
a graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a
clique
of
of colouring
a graphIrvin
such
that no
twoGUNAWAN
adjacent vertices have the same colour. Note that4.1
if there
is a cliquegr
of
Jonathan
Irvin
Jonathan
GUNAWAN
colours.
the
four
colour
theorem,
any
can be
coloured
with
at most
four
the four By
colour
theorem,
any
planar
graph
can
begraph
with
at most
four
colours.
2005).
Since
at most
vertices
inentire
setPlanar
is directly
con
most
colours
are
required
to
colour
a planar
there
does
not
exist
athe
clique
4.
If vertices
N

2four
(mod
3).
F
(Nplanar
) can
becoloured
partitioned
into
two
multisets
of (Gonthier
equal
sum.
examples.
aph,Theorem
the kset
of
theat
inside
thevertices
clique
must
be
coloured
with
kgraph,
colours.
Therefore,
the
size
in
a
graph,
the
set
of
the
inside
the
clique
must
be
coloured
with
k
colours.
Therefore,
the
entire
Jonathan
Irvin
GUNAWAN
Jonathan
Irvin
GUNAWAN
Proof.
Assign
fcolour
(1)
toawe
Aplanar
and
fgraph,
(2)
tonot
B.
Since
(1)
=
f (2),
wethan
are
now
trying
to pa
orem,
anyatcolours
planar
graph
can be
coloured
with
at
most
four
. Since
most four
colours
are
required
does
exist
most
four
are required
tofour
colour
a to
planar
graph,
there
does
exist
athat
clique
with
more
vertices.
H
on
graph
is NP-hard.
with
more
than
vertices.
Hence,
can
solve
the
problem
byfnot
checking
whether
there
Planar
graph
is athere
graph
can
begeneral
drawn
on
a four
at
surface
with
Since f (1) = f (2), we are now trying to partition F (N ) = F (N )
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
f
(1)

f
(2).
F
(N
)
will
have
N

2
elements.
Since
N

2
(mod
3),
we
obtain
N
w2
es.
required
to
colour
a
planar
graph,
there
does
not
exist
four
vertices.
Hence,
wethe
can
solve
by
checking
whether
there
is
a
clique
Hence,
we can
problem
by problem
checking
whether
there
is
a
clique
with
four
vertices.
If
there
is
no
clique
of
colouring
a
graph
such
that
is solve
a clique
with
fourthe
vertices.
If there
is
no
clique
with
four
vertices,
we
check
whether
et al. 2001). There are many graph problems which
are easy
to so
Number
oftheore
edg

2 elements. Since N 2 (mod 3), we obtain N 4.1.1


n GUNAWAN
fno
(1)

f (2).
F
(Nchecking
) vertices,
will
have
N

(mod
3). our
By
lemma
Jonathan
Irvin
GUNAWAN
3,whether
Fwith
(Ncheck
) can
beispartitioned
two multisets
of equal
sum,
which
implies
solve
theclique
problem
by
there
a clique
re
iswith
with
four
we
whether
therewith
isinto
a clique
withisthree
vertices.
ue
four
vertices,
we
whether
there
three
vertices.
Finding
whether
there
is
a the
clique
with
k
there
is
acheck
clique
three
vertices.
Finding
whether
there
a clique
with
vertices
can
size
k2in
a0graph,
set
of
the
examples.
k
kthree
4of edgeswhich
F (N
)whether
can
besolved
partitioned
into
multisets
of equal
sum,
which
our
theorem.
s,a we
check
there
is
a clique
with
clique
with
k vertices
can
be
solved
naively
inInvertices.
O(V
).the
Therefore,
theimplies
whole
solution
th
k 3,vertices
can
be
naively
in two
O(V
).. Therefore,
Therefore,
the
whole
solution
simple
general
graph,
the
number
up to a qua
naively
in
whole
solution
takes
is
takes
O(V
) time, can be
is polynomial.
Therefore,2 solving this2 problem is2 reduced to checking whether N 1 (mod 3). W
k
solved
in
O(V
).improved
Therefore,
the
whole
solution
is polynomial.
The
solution
can solution
betoimproved
to
O(V of).
Instead
of
having
four
nested
polynomial.
The
improved
to
having
four
nested
loopsindependently,
ial.
Thenaively
solution
can
be
O(Vcan
).be
Instead
having
nested
vertices
(i.e.
O(Vfour
)).
Thisloops
isof
not
the
case
forvertices
planar
graph. In of
a pl
to
nd
four
. Instead
4.1.1
Number
Jonathan
Irvin
GUNAWAN
Therefore, solving
this
problem
is reduced
checkingofwhether
N
1in(mod
3). We can
solve
this in O(1).
We
will provide
moretoexamples
special
cases
the following
section.
2
an
be
improved
to
O(V
).
Instead
of
having
four
nested
totwo
find
four
independently,
we
can
two
nested
loops
over
the edges
instead
sntly,
independently,
cannested
havevertices
two nested
loops
overinstead
the
edges
and
test
whether
we can havewe
loops
over
the
edges
and
test
whether
holds
for
V have
3instead
by using
the
Eulers
formula.
Therefore,
number
the
four
vertices
(which
are thethe
endpoint
We will provide more examples of special cases in the following
section.
2 the the
2 takes
wo
nested
over
the
edges
instead
testthat
whether
In
simple
general
graph,
of
can
be up
to a
and
the
four
vertices
(which
are
the
endpoint
twoasnumber
edges)
a clique.
re the
of
thetest
twowhether
edges)
form
aand
clique.
This
solution
),same
which
isO(V
the
oint
of endpoint
the loops
two edges)
form
a clique.
This
solution
takes
O(E
),
which
is of
the
has
O(E)
in
itsO(E
running
time
can
be2form
into
O(V
). Comp
)changed
in edges
planar
graph.
2
2
isvertices
the
same
as

in
planar
graph.
s)graph.
form a clique. This solution takes
takes O(E ),, which
the4
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
itIno
Some example of special cases
holds
for
V

3
by
using
the
Eulers
formula.
Therefore,
the
num
the number of of
connected
components
using DFS in a general graph
t
4 Some example
special
cases
4.1.3.
Problem
Example
that
has examples
O(E)
in its
time that
can
be
changed
into
O(Vthe
). C
We willexample
look at some
common
of ifrunning
special
cases
may
occur
in
competitive
planar
graph.
Therefore,
the problem
requires
us
to compute
n
4.1.3 example
Problem
4.1.3 Problem
We
use
a that
past
programm
Wesome
will common
use a pastexamples
competitive
programming
problem
illustrate
the
importance
of
the
Bellman-Ford
algorithm
takes
O(V
E)
(Halim
& 100,
Halim
2013),
will look at
of special
cases
that
may
occur
in will
competitive
programming
problems.
lemWe
example
graph,
even though
theto
constraint
states
Vcompetitive

000,
E but
10
etitive programming
illustrate
theThe
importance
of
the
properties
in
a
planar
ramming
problemproperties
to problem
illustrate
the
importance
of Traffic
the
properties
in
a
planar
in ato
planar
graph.
problem
from
Central
European
Olympiad
in
graph.
The
Trac
problem
from
Centra
the
number
of
connected
components
using
DFS
in
a
general
gra
under one second (in competitive
programming,
we assume that 1
4.1 this
Planar
graphs
ontral
illustrate
the importance
of
the properties
in a2011
planar
lem
from
Central
EuropeaninOlympiad
in (CEOI)
Informatics
(CEOI)
2011this
illustrates
concept
European
Olympiad
Informatics
illustrates
concept
Informatics
(CEOI)
2011
illustrates
this
concept
well.
In thiswell.
problem,
there
isrequires
a directed
In problem
this
problem,
there
directed t
planar
graph.
Therefore,
if the
us is
toacompute
(Halim
& Halim
2013)).
4.1
Planar
graphs
mpiad
Informatics
2011
this
concept
ere
isgraph
aindirected
graph
up
to000
Villustrates
=
300,is000
vertices
given
a
2D
plane.
There
are
graph
with
up
to
vertices
in
a
2D
plane.
There
are
two
vertical
lines
cted
with up
to(CEOI)
Vwith
= 300,
vertices
given
ingraph,
athat
2D
plane.
There
are
two
vertical
lines
denoted
as
left
and
rig
Planar
graph
a graph
can
be
drawn
on
a
at
surface
without
having
two
edges
even though the constraint states that V 100, 000,
E
Vleft
= 300,
000
vertices
given
a contained
2D
plane.
There
are
denoted
as that
left
and
right.
All
are
contained
within
the
left
and
right
lines,
as
andgraph
right.
Allgraph
vertices
are
within
the
left
and
right
lines,
with
some
dto
right.
All
vertices
contained
within
theThere
left
and
right
lines,
with
some
vertices
possibly
lying
on
these
two
lines.
Planar
is aare
can
be
drawn
onvertices
a under
at
surface
without
having
two
edges
crossing
each
other
(West
etin
al.
2001).
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
plan
one second (in competitive
programming,
we
assume
tha
4.1.2
Clique pr
2 the Maximum
2of visitable
with
some
vertices
possibly
lying
onsome
these
two
lines.
The ifproblem
requires
contestant
are
contained
within
the
left
and
right
lines,
with
these
two2001).
lines.
The
problem
requires
the
contestant
to
print
the
number
ines.
The
problem
requires
the
contestant
to
print
the
number
of solve
visitable
vertices
lying
on the
line from
eve
et
al.
There
are
many
graph
problems
which
are
easy
to
the
graph
is planar.
Weright
will provide
severa
examples.
(Halim
&
Halim
2013)).
2
2 lying on the right line from every vertex lying
to vertex
print
number
of(which
visitable
vertices
the contestant
tothe
print
the
number
htevery
line
from
every
lying
on
the
left of
line
(which
we
shall
call problem
left
vertices
andus for
mrequires
vertex
lying
on the
left
line
wevisitable
shall
call
left
vertices
and
The
Maximum
Clique
requires
to nd
the maximum
set o
right
vertices
simplicity).
An instanc
examples.
on
the
left
(which
we
shall
call
left
and
rightconnected
vertices forbysimplicity).
An reduction from
on the
(which
we
shall
call
left
vertices
and
ity).
An
instance
for
this
problem
can
be
seen
gure
tance
forleft
this line
problem
can
beline
seen
on gure
5. on
vertices
in5.vertices
the set is
directly
an
edge.
By
4.1.1 Number of edges
Maximum Clique
for this problem can beon
seen on Fig.
5. is NP-hard. However, 4.1.2
em can be seen oninstance
gure 5.
graph
it is easy to solve this prob
4.1.1general
Number
of edges
simple
general
graph,
number
of
edges
upadjacent
to
a to
quadratic
withsa
The bruteInforce
solution
for of
this
problem
is
runClique
DFS
from
every
left
vertex
which
Thethe
Maximum
problem
requires
us
nd the order
maximum
colouring
a to
graph
such
thatcan
no be
two
vertices
have
the
2 . Itcan
In simple general
the number
edges
be
up
to
a
quadratic
order
with
respect
to
the
number
of
givesgraph,
us a running
time
ofof
is
very
difficult
to
find
a
solution
(if
any)
faster
than
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction

size k in a graph, the set of the vertices inside the clique must be m
co
forThis
this
However,
there
is
an
important
constraint
on
the
problem.
The
vertices (i.e. O(V 2 )).
isproblem.
not
case
planar
graph.
In
a
planar
graph,
we
may
show
that
E

3V

holds
for the
V
3 byforusing
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
on general graph is NP-hard. However, it is easy to solve this6)
given the
in
this
problem
is
planar
graph.
Wechanged
first
relabel
the
right
vertices
holds for V graph
3 by using
Eulers
formula.
the
of edges
isno
O(V
).).adjacent
Naturally,
any
algorithm
that
has
O(E)
inalways
its Therefore,
running
time
can
be
into
O(V
Computing
shortest
of acolouring
anumber
graph
such
that
two
vertices
havepat
th
Jonathan
Irvin
GUNAWAN
2
in
ascending
order
according
to
the
y-coordinate.
The
planar
properties
ensures
that
for
that has O(E) in its running
time can be
changed
into
O(V
). Computing
pathbut
in
a general
graph
using
Bellman-Ford
algorithm
takes
E)
(Halim
& Halim
it
only
O(V
) in
size
k inO(V
a graph,
the set
ofshortest
the 2013),
vertices
inside
thetakes
clique
must
b
2
Bellman-Ford algorithm takes
E) (Halim
& Halim
2013), butusing
it only
takes
) in graph
a planar
graph.
the O(V
number
of connected
components
DFS
in aO(V
general
takes
O(V Counting
+ E), b
the number of connected
components
DFS in ifa the
general
graph
takes O(V
E), but the
it only
takesofO(V
) in a
planar graph.using
Therefore,
problem
requires
us to+compute
number
connect
2
vertex v is visitable from vertex u if thereJonathan
is a path from
u to vGUNAWAN
Irvin
2 in a planar
planar graph. Therefore, ifgraph,
the problem
requires
us
to
compute
the
number
of
connected
components
even though the constraint states that V 100, 000, E 100, 000 , the stand
graph, even though the constraint
that(inV competitive
100, 000, programming,
E 100, 0002 ,we
theassume
standard
DFS
solutionoperations
still runs
under onestates
second
that
1 million
under one second (in competitive
(Halim &programming,
Halim 2013)).we assume that 1 million operations can be done in 1 second
(Halim & Halim 2013)).

Understanding Unsolvable Problem

95

Fig. 5. An instance of problem Traffic. In this example, the expected output is {4, 4, 0, 2},
since the top left vertex can visit 4 right vertices, the second top left vertex can2 visit 4
of O(V ). It is very dicult to nd a
right vertices, the third top left vertex cannot visit any right vertex, and the bottom left
important constraint on the problem.
vertex can visit 2 right vertices.

the right vertices in ascending order


left
the sequence
left
the
of
visitable
left
is is anof right vis
2
2 vertices from thatvertex,
2right
or
this
It is
problem.
very
However,
to nd
there
a solution
an sequence
(if any)
faster
O(V
) forHowever,
this problem.
there
cult
r).this
problem.
to
nddicult
aevery
solution
However,
(ifvertex,
there
any)
isisfaster
an
than
O(V
) forthan
this
problem.
thereHowever,
is an vertex
we
have
removed
all
right vertices w
agraph.
contiguous
sequence,
assuming
we problem
have
removed
all aright
vertices
arerelabel
ways
constraint
planar graph.
on
the graph
problem.
We rst
rst
relabel
The
given that
inis this
is always
planar
graph.
We rst
ways
nntthe
aaproblem.
planar
The
We
given
relabel
in graph
this
problem
always
a planar
graph.
We
rst
relabelwhich
not visitable from any left vertex. With this property, there is a O(V log V ) solution
solution (CEOI 2011 Solu
ht
anar
vertices
properties
in ascending
ensures that
that
order
foraccording
every
to theThe
y-coordinate.
The planar
properties
anar
scending
properties
order
ensures
according
to for
the
every
y-coordinate.
planar properties
ensures
that forensures
every that for every
(CEOI 2011 Solutions, n.d.).
tex,
contiguous
sequence
sequence,
of right
assuming
visitable
that
vertices
vertex issequence,
a contiguous
sequence,
aace
contiguous
ofthe
right
visitable
sequence,
vertices
assuming
fromthat
that
left from
vertexthat
is aleft
contiguous
assuming
that assuming that
evertex.
removed
With
allthis
this
right
property,
vertices
there
which
a from
not any
visitable
anyWith
leftthis
vertex.
Withthere
this property,
there is a
ight
ertex.
vertices
With
which
property,
are notthere
visitable
isis aare
left from
vertex.
property,
is a
g V ) solution
(CEOI
2011
Solutions
n.d.).
CEOI
2011 Solutions
n.d.).
4.2. Bipartite Graph
Bipartite graph is a graph in which th

edges connect a vertex from U and a


the problem statement does not explic
Bipartite graph is a graph in which the vertices can be partitioned into two disjoint sets
used as an introduction for this pape
and
such
such
that
all edges
from
and Va vertex
from
Somethat all
oaph
edisjoint
disjoint
graph
issets
sets
a graph
and
inVVwhich
such
that
canconnect
be partitioned
into
two
sets U
andallV .such
in which
the
UU and
vertices
canthe
that
bevertices
partitioned
all
into
twoa vertex
disjoint
sets
U disjoint
and
such
that
instatement
subtask 5does
of this
problem implicit
problems
have
a
bipartite
graph
as
an
input
although
the
problem
not
onnect
bipartite
a
vertex
graph
from
as
an
U
input
and
a
although
vertex
from
V
.
Some
problems
have
a
bipartite
graph
as
an
input
although
bipartite
from U and
graph
a vertex
as an input
from Valthough
. Some problems have a bipartite graph as an input although
graph
problems
that
are
NP-hard for g
explicitly
state
that
the
graph
must
be bipartite.
problem
that
we usedthat we
blem
ust
bestatement
bipartite.
does
The
not
problem
explicitly
thatgiven
state
we given
thatinput
the
given
input
graph
must
beThe
bipartite.
The
ust
does
be
not
bipartite.
explicitly
The
state
problem
that
that
the
we
input
graph
must
be bipartite.
The
problem
that
weproblem
bipartite
graph
and bipartite matchin
as an
for
paper,
IOIis
2014
Friend
is aconstruction
very goodThe
example.
The
construcmple.
Thepaper,
construction
for
this
ofpaper,
the graph
graph
IOI
2014
Friend
a very
good
example.
of the graph
mple.
nanforintroduction
this
The
construction
IOIintroduction
2014
of
the
Friend
isthis
a very
good
example.
The
ofconstruction
the graph
that
this
type
of
problem may be con
tionensures
of
the
graph
in
subtask
5 ofthe
this
problem
thatseveral
the There
final graph
ask
ways
5be
be
ofimplicitly
this
bipartite.
problem
There
implicitly
are several
several
ensures
that
nal
graph
will
alwaysensures
be bipartite.
are several
ways
oblem
bipartite.
There
are
that
the
nal graph
will
always
be implicitly
bipartite.
There
are
will
always
be
bipartite.
There
are solvable
several time
graph
that
NP-hard
general Since
al
roblems
time ififthat
the
are
graph
NP-hard
bipartite.
forbut
general
Since
graph
in polynomial
time
ifare
the
graph
isforbipartite.
el time
NP-hard
the
forgraph
general
isis bipartite.
graph
Since
solvable
in but
polynomial
if problems
the graph
is bipartite.
Since
4.2.1
Vertex Cov
graph
but
solvable
in
polynomial
time
if
the
graph
is
bipartite.
Since
bipartite
graph
andexpect
ellabus
graph(Forisek
(Forisek
and bipartite
2015),
matching
we can
can expect
expect
was recently
in IOI(Forisek
2015 syllabus
2015), we can
partite
labus
matching
2015),
was recently
we
included
in IOI included
2015 syllabus
2015),(Forisek
we can expect
bipartite
matching
was
recently
included
in
IOI
2015
syllabus
(Foriek,
2015),
we
can
slll take
type
take
abe
look
problem
at several
several
mayinbe
examples.
conceived
in the
nearWe
future
IOI.a We
take a look
at several
examples.
em
mayaof
look
conceived
at
examples.
the
near future
of IOI.
will of
take
lookwill
at several
examples.
As we
discussed
in an earlier section, b
expect that this type of problem may be conceived in the near future of IOI. We will
are NP-hard. However, both of these
take a look at several examples.
aximum
4.2.1
matching)
Vertex
Cover and Independent
Set (and
maximum matching)
aximum
Vertex
matching)
Cover
and Independent
Set (and maximum
matching)
theorem, the size of the minimum ve
matching (Bondy & Murty 1976), and
Cover
Independent
(and Maximum
Matching)
iscussed
MAX-INDEPENDENT-SET
in an 4.2.1.
earlierofVertex
section,
problems
both and
of the
MIN-VERTEX-COVER
and MAX-INDEPENDENT-SET
problems
MAX-INDEPENDENT-SET
arlier section,
both
the MIN-VERTEX-COVER
problems
andSetMAX-INDEPENDENT-SET
problems
number ofand
the vertices minus the size
Asproblems
we
discussed
in
an earlier
section,
ofon
thebipartite
MIN-VERTEX-COVER
time
on
However,
bipartite
both
graph.
of these
By
Konigs
problems
solvableboth
in polynomial
time
on bipartite
graph.MAXBy Konigs
time
,hard.
both
on
ofbipartite
these
graph.
By
areKonigs
solvable
in are
polynomial
time
graph.
By Konigs
nding
the size of the maximum bip
INDEPENDENTSET
problems
NP-hard.
However,
bothsize
of to
these
m,
to
the size
size of
ofvertex
the
minimum
maximum
cover
in bipartite
graph
equal
to the
of
the problems
maximum are
bipartite
he
o the
minimum
the
maximum
cover in vertex
bipartite
bipartite
graph
is are
equal
to the issize
of the
maximum
bipartite
maximum
matching
in bipartite graph
solvable
in
polynomial
time
on
bipartite
graph.
By
Konigs
theorem,
the
size
of
the
gset
set
(Bondy
in bipartite
bipartite
&and
Murty
graph
1976),
equal
and
to
thethe
the
size of independent
the maximum
in bipartite
graph
urty
in
1976),
graph
the
size
isis of
equal
the to
maximum
setindependent
in bipartite set
graph
is equal to
the is equal to the
tomaximum
solve, as compared
to using Edmon
minimum
vertex
in bipartite
graph
ismatching.
equalboth
to the
size of the
herefore,
of the the
vertices
both
problems
minus
the
are
size
equivalent
ofcover
the maximum
bipartite
Therefore,
both
problemsbipartite
are equivalent
minus
erefore,
both
sizeproblems
of
the maximum
are
equivalent
bipartite
matching.
Therefore,
problems
are
equivalent
5thindependent
subtask of IOI
2014 Friend.
3
3
matching
(Bondy
and
Murty,
1976),
and
the
size
of
the
maximum
set
in
3
3
ng
n O(V
the size
ofbipartite
the
maximum
bipartite
whichincan
be solved
O(V
time.
Finding
the size
size
of
thematching,
O(V )the
time.
he
maximum
matching,
which
can be solved
)) time.
Finding
the
of
the
O(V
) time.inFinding
sizeFinding
of the the size of the
imum-Flow
m
matching
algorithm
in
bipartite
is
much
graph
simpler
using
Hopcroft-Karp
algorithm
or
Maximum-Flow
algorithm
mum-Flow
bipartite graph
algorithm
using is
Hopcroft-Karp
much simpleralgorithm or Maximum-Flow algorithm is much simpleris much simpler
h.
, as
This
compared
actually
to using
the solution
solution
Edmonds
of the
Blossom
the on general
algorithm
on general
graph. This
is actually
h.
to
This
using
isisEdmonds
actually
the
Blossom
algorithm
of
graph.
This is actually
the solution
of the solution of the
4.3
of IOI 2014 Friend.
4ask
Friend.

4.2

4.2 Graph
Bipartite Graph
Bipartite

A directed acyclic graph is a directed g

that
graph
problems
NP-hard
forthe
general
graph
but
inmatching
polynomial
if the included
graph is in
bipartite.
hat are
NP-hard
graph
but time
solvable
in graph
polynomial
timesolvable
if Since
the graph
is bipartite.
Since
polynomial
time
iffor
thegeneral
graph
is are
bipartite.
Since
neral
graph
but solvable
inthat
polynomial
if
is bipartite.
bipartite
graph
and
bipartite
wastime
recently
IOI 20
4.2.1
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
bipartite
graph
and
bipartite
matching
was
recently
included
in IOI
weIOI.
can W
and
bipartite
matching
recently
included
in
IOI
2015
syllabus
(Forisek
2015),
wesyllabus
can expect
I 2015
syllabus
(Forisek
2015),
wesyllabus
can
expect
was
recently
included
inwas
IOI
2015
(Forisek
2015),
we
expect
that
this
type
of can
problem
may
be2015
conceived
in (Forisek
the near 2015),
future of
that
this
typeof
ofIOI.
problem
may
be aconceived
in the
near
future
ofatIOI.
We examples.
will take a look at several examp
problem
may
be
conceived
in
the
near
future
of
IOI.
We
will
take
a
look
several
OI.
We
will
take
a
look
at
several
examples.
ived
in
the
near
future
We
will
take
look
at
several
examples.
e discussed in an earlier section, both of the MIN-VERTEX-COVER and MAX-INDEPENDENT-SET problems
4.2.1 Vertex
Independent
NP-hard. However,
both of these problems are solvableJ.I.inGunawan
polynomial
time onCover
bipartiteand
graph.
By Konigs Set (a
96matching)
4.2.1
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
tr.2.1
(and
maximum
and
Independent
Set
(and
maximum
matching)
em, the size of the minimum vertex cover in As
bipartite
graph in
is equal
to the
size of
theofmaximum
bipartite
we discussed
an earlier
section,
both
the MIN-VERTEX-COVER
hing
(Bondy
&
Murty
1976),
and
the
size
of
the
maximum
independent
set
in
bipartite
graph
is
equal
to thein polyno
bipartite
graph
is equal
to theare
number
of MIN-VERTEX-COVER
the
vertices
minusofthe
size
of
the maximum
in
Assection,
we discussed
in
an earlier
section,
both
of the
andproblems
MAX-INDEPENDENT-SET
pro
nh an
earlier
both of
the
MIN-VERTEX-COVER
and
MAX-INDEPENDENT-SET
problems
VER
and
MAX-INDEPENDENT-SET
problems
of the
MIN-VERTEX-COVER
and
MAX-INDEPENDENT-SET
problems
NP-hard.
However,
both
these
are solvable
ber
of theboth
vertices
minus
the
size are
ofboth
the
maximum
bipartite
Therefore,
problems
are
equivalent
bipartite
matching.
Therefore,
both
problems
are
equivalent
toboth
finding
the
size
of
the graph.
are solvable
NP-hard.
However,
ofon
these
problems
are
solvable
in polynomial
time
on
bipartite
owever,
of
problems
solvable
in
polynomial
time
bipartite
graph.
By
Konigs
lynomial
time
onthese
bipartite
graph.
By
Konigs
problems
are
in
polynomial
time
bipartite
graph.
By
Konigs
theorem,
thematching.
size
ofon
the
minimum
vertex
cover
in
bipartite
graphBy
is eK
3 time. Finding the size
maximum
bipartite
which
can
bebe
solved
in
nding
the minimum
size
of size
the
maximum
bipartite
matching,
which
caninto
solved
in
)equal
time.
Finding
ofmaximum
the indepe
eisofequal
the
vertex
cover
in bipartite
graph
is cover
equal
the
size
of O(V
the ismaximum
bipartite
theorem,
the
size
the
minimum
vertex
bipartite
graph
to
the
ofsize
the
bi
to
the
of
the
maximum
bipartite
ex
cover
in
bipartite
graph
isof
equal
tomatching,
the
size
of
the
maximum
matching
(Bondy
&bipartite
Murty
1976),
and the
size size
ofthe
the
maximum
of
the
maximum
matching
in
bipartite
graph
using
Hopcroft-Karp
algorithm
or
Maximum
matching
in
bipartite
graph
using
Hopcroft-Karp
algorithm
or
Maximum-Flow
algorithm
is
much
simpler
(Bondy
& Murty
1976),
and
the graph
size
of isthe
maximum
setmaximum
in bipartite
graph ismatchin
equal
yhe&size
Murty
1976),
and
theindependent
size
ofisthe
maximum
independent
set
in bipartite
graph
to
the bipartite
dependent
set
in
bipartite
graph
equal
of matching
the
maximum
setto
in the
bipartite
equal
tominus
the independent
number
of the
vertices
the
sizeisofequal
the
mum-Flow
algorithm
is much
simpler
toTherefore,
solve,
asgraph.
compared
using
Edmonds
Bloslve,
asminus
compared
to
Edmonds
Blossom
algorithm
on
general
This to
is bipartite
actually
the
solution
of the
ertices
number
of using
the
vertices
minus
the
size
of
the
maximum
bipartite
matching.
Therefore,
both
problems
rtices
the
size
of problems
the
maximum
bipartite
both
problems
are
equivalent
ching.
Therefore,
both
are
equivalent
the maximum
bipartite
matching.
Therefore,
both
problems
are
tomatching.
nding
the
sizeequivalent
of
the
maximum
matching,
which
canare
beequ
sol
so
algorithm
on
general
graph.
This
is
actually
of
IOI
3the solution of the 5th subtask
3
3 som
3the
ubtask
IOI
2014
Friend.
toO(V
nding
the
size
of
the
maximum
bipartite
matching,
which
can
be
solved
in
O(V
)
time.
Finding
the
size
e solved
of matching,
theofin
maximum
bipartite
matching,
which
can
be
solved
in
O(V
)
time.
Finding
the
size
of
the
ertite
)
time.
Finding
the
size
of
which can be solved in O(V ) time.
Finding
the sizeinofbipartite
the
maximum
matching
graph using Hopcroft-Karp algorithm or
2014
Friend.
ingorin
bipartite
graph
using
Hopcroft-Karp
algorithm
orHopcroft-Karp
Maximum-Flow
algorithm
much
simpleralgorithm
maximum
matching
bipartite
graph
algorithm
or isMaximum-Flow
algorithmonis general
much s
m
Maximum-Flow
algorithm
much simpler
sing
Hopcroft-Karp
algorithm
orinisMaximum-Flow
algorithm
is much simpler
to using
solve,
as
compared
to
using
Edmonds
Blossom
th
th
to
solve,
toalgorithm
usingThis
Edmonds
Blossom
algorithm
on general
is actually the solution
pared
to using
Edmonds
Blossom
on
general
graph.
This
is
thegraph.
solutionThis
of the
graph.
This
is as
actually
the graph.
solution
of
the
seral
Blossom
algorithm
oncompared
general
is 5actually
theofsolution
of actually
the
subtask
IOI
2014
Friend.
5th subtask
IOI 2014
Friend.
OI 2014 Friend.
4.3
Directed
Acyclic Graph
4.3. of
Directed
Acyclic
Graph

ected acyclic graph is a directed graph that does not contain any cycle. Similar to planar and bipartite graphs,
4.3acyclic
Directed Acyclic
are several graphAproblems
that aregraph
muchiseasier
to solve
if the
is a contain
directed
directed acyclic
a directed
graph
thatgraph
does not
any cycle.graph.
Similar to

4.3 Directed
Acyclic Graph
4.3 Directed
Graph
c Graph
Directed Acyclic
Graph Acyclic

planar and bipartite graphs, A


there
are several
thatgraph
are much
easiernot
to contain any c
directed
acyclicgraph
graph problems
is a directed
that does
Minimum
Path
Cover
A
acyclic
graph
is4.3.1
anot
graph
that
does
not graphs,
contain
cycle.
to
planar
solve
if the
graph
isSimilar
a directed
directed
acyclic
graph.
cnygraph
a directed
graph
that
does
contain
anyare
cycle.
Similar
to
planarany
andthat
bipartite
graphs,
cycle.
Similar
planar
and
bipartite
graphs,
aph
that isdoes
notto
contain
any
cycle.
tothere
planar
and
bipartite
several
graph
problems
areSimilar
much
easier
to and
solvebipartite
if the gr
g
there
are
several
graph
problems
thatif are
much
easier
to solveacyclic
if the graph
is a directed acyclic graph.
graph
problems
that
are
much
easier
to
solve
the
graph
is
a
directed
graph.
he
graph
is
a
directed
acyclic
graph.
re
much
easier
to
solve
if
the
graph
is
a
directed
acyclic
graph.
-PATH-COVER is a problem that requries us to nd the minimum number of vertex-disjoint paths needed
4.3.1. Minimum Path Cover
4.3.1
Minimum
Path Cov
over all of the vertices in a graph. By a simple reduction from Hamiltonian Path, this
problem
is NP-hard.
MIN-PATH-COVER
is a Path
problem
that requires
us Path
to findCover
the minimum number of
4.3.1
Minimum
Cover
4.3.1
Minimum
Cover
4.3.1
Minimum
Path
Cover
aph has a Hamiltonian Path if and only if we MIN-PATH-COVER
only need one path to
all ofthat
the vertices.
However,
is cover
a problem
requries
us
to rend this
the minimu
vertex-disjoint paths needed to cover all of the vertices
in a graph.
By a simple
em
can
be
solved
in
polynomial
time
for
a
directed
acyclic
graph.
For
a
graph
G
=
(V,
E),
we
create
a new from
VER
is
a
problem
that
requries
us
to
nd
the
minimum
number
of
vertex-disjoint
paths
needed
is
anumber
problem
that
requries
to isnd
the minimum
number
of vertex-disjoint
pathsHn
imum number
of duction
vertex-disjoint
paths
needed
requries
usMIN-PATH-COVER
to nd
the minimum
of Path,
vertex-disjoint
needed
to cover
all us
ofpaths
the
vertices
in Aa graph
graph.
ByaaHamiltonian
simple
reduction
from
Hamiltonian
this
problem
NP-hard.
has

hhe
G
(Vout

,all
E this
),
where
Voutifis=
= VA
and
E
=
{(u,
v)

Vout

Vthe
:ifvertices.
(u,
v)isonly
NP-hard.
E}.
Then
it can
beone path
in
in
toincover
of
the
inVin
aonly
graph.
By
ahas
simple
reduction
from
Hamiltonian
this
problem
is NP
vertices
a VPath,
graph.
a vertices
simple
reduction
from
Hamiltonian
Path,
problem
m
Hamiltonian
problem
NP-hard.
By
a=simple
reduction
from
Hamiltonian
Path,
this
problem
is
NP-hard.
graph
a to
Hamiltonian
Path
and
ifPath,
we
only
need
Path
ifBy
and
only
we
need
one
path
cover
allthis
of
However,
this

n
bytoKonigs
Theorem
that
G
has
a
matching
of
size
m
if
and
only
if
there
exist
|V
|

m
vertex-disjoint
graph
has
avertices.
Hamiltonian
Path
if
and
only
if
we
only
need
one
path
to
cover
all
of
the
vertices.
Howeve
amiltonian
Path
ifproblem
and
only
if
we
only
need
one
path
to
cover
all
of
the
vertices.
However,
this
ath
all
of
the
However,
this
only
if cover
weAonly
need
one
path
to
cover
all
of
the
vertices.
However,
this
problem
can
be
solved
in
polynomial
time
for
a
directed
acyclic
graph.
can be solved in polynomial time for a directed acyclic graph. For a graph
For
ssolved
that
cover
all ofacyclic
vertices
indirected
G.
for, awe
graph.
aout
graph
=
E), we
create
ainnew
problem
can
begraph.
solved
in
polynomial
time
for
a we
directed
For
a=graph
(V,
create
aph.
apolynomial
graph
Gthe
=time
(V,
E),
we
create
anew
new
me
forFor
aindirected
For
a graph
Ggraph
=
(V,G
E),
create
aG,new
graph
=
(V
Vacyclic
E (V,
),,graph.
where
Vout
Vin
=GV=and
E =we{(u,
v)
create
aacyclic
where
andE),
in
out
in
out

graph G = (V

inV=
E and
),it
V{(u,
V
=Then
Vand
E
=be
{(u,
v)by
Konigs
Vhas

V
(u, v)
E}.mThen
it
V
EV
),
V=
=
Vv)
v)
VitTheorem
: (u,
v)
E}.
Then
itmatching
can

V,out
where
V
v){(u,
E}.
Then
can
be
.out
can
be
shown
Theorem
that
=
Vin
=
and
V,Vout
where
VEin =
: (u,
v)=
by
E}.
Then
it
can
shown
Konigs
that
G
ofsize
if and
out
in
out
inV
out a
in :be
out
in
in :E(u,
ttv)
in

Konigs
by
Theorem
that
athat
of of
size
|V | m vertex-d
has
matching
size
has
and
only
there
exist
vertex-disjoint
vertex-disjoint
s
that
G
has
matching
of
sizeGexist
m
ifif and
only
ifif there
exist
|Vif |and
monly
and
only ifshown
there
exist

monly
vertex-disjoint
4.4
Miscellaneous
s aTheorem
matching
of size
m|Vifa| and
ifof
there
|V
| matching

m
vertex-disjoint
paths
cover
all
themvertices
in
G.if there existpaths
that
cover all
all of
of the
the vertices in
that
in G..
vertices
in cover
G.
.all of the paths
4.4.1 Special case of CNF-SAT problem

4.4

Miscellaneous

will
use Google
Code Jam 4.4
2008 Round
1A Milkshake
for this example. This problem requires the
Miscellaneous
4.4problem
Miscellaneous
ous
4.4
Miscellaneous
4.4. Miscellaneous
4.4.1
Special
case with
of CNF-SAT
estant to nd a solution with the minimum number of true variables that satisfy
a CNF-SAT
problem
up
4.4.1
Special
case
of
CNF-SAT
problem
4.4.1
Special
case
of
CNF-SAT
problem
SAT
problem
Special
case of CNF-SAT problem
We will
use Google Code Jam 2008 Round 1A Milkshake problem fo
4.4.1. Special Case of CNF-SAT
Problem
gle
Code
Jam
2008
Round
1A
Milkshake
problem
for
example.
Thiswith
problem
requires
We
will
use
Google
Code
Jam
2008
Round
1Athis
problem
for
example.
This of
problem
requir
m
for1A
this
example.
requires
und
Milkshake
problem
this
example.
This
requires
the
contestant
toMilkshake
nd
aMilkshake
solution
thethis
minimum
number
true variable
than
Irvin
GUNAWAN
WeThis
will problem
use for
Google
Code the
Jam
2008problem
Round
1A
problem
for
this the
example.
contestant
to
nd
a problem
solution
with
the
minimum
number
of atrue
variables
that satisfy
a CNF-SAT
problem w
dinimum
a solution
withofThis
the
minimum
number
ofthetrue
variables
satisfy
CNF-SAT
withnumber
up
ables
that
satisfy
a true
CNF-SAT
up
number
variables
that satisfy
a CNF-SAT
problem
with
upwith
problem
requires
contestant
tothat
find
a solution
theproblem
minimum
of

true variables that satisfy a Jonathan


CNF-SATIrvin
problem
with up to 2,000 variables (Google
GUNAWAN
Code
2008 Round 1A, Milkshake problem, n.d.). The CNF-SAT is a satisfiability
IrvinJam
GUNAWAN
UNAWANJonathan
problem given in a conjunctive normal form (i.e. conjunction of disjunction of literals)
which was proven to be NP-hard (Cook, 1971). Therefore, it is unlikely that there is an
algorithm to solve a CNF-SAT problem with 2,000 variables in less than 8 minutes3.
However, there is a special property in this problem, in which at most one unnegated
literal exists in each clause. Therefore, all clauses can be converted into Horn clauses.
With this property, a linear time algorithm exists. (Google Code Jam 2008 Round 1A,
Milkshake solution, n.d.).

In Google Code Jam, contestants are given 8 minutes to produce the output upon downloading the input.

Understanding Unsolvable Problem

97

5. Conclusion
In conclusion, we can use a well-known reduction technique to prove that a problem that
we are currently attempting to solve is impossible (or at least it is very hard such that no
people has been able to solve it for more than 40 years). In competitive programming
(including IOI), understanding this technique is essential so that we will not be stuck at
trying to solve an impossible problem, thus prompting us to find another way to solve
the problem. To prove that a problem is NP-hard, it is good to know as many NP-hard
problems as possible, so that we can reduce from any one of the problems that we know
to the new problem. Some of the classic NP-hard problems include 3-SAT, Vertex Cover,
Independent Set, and Subset Sum. After realizing that the problem is NP-hard, we must
be able to find the special case that makes the problem solvable. We must be able to find
a special property that breaks the reduction proof. Having a lot of practice on these kind
of problems will help us to familiarize with the possibilities of a special case. Some of
the common special cases include planar, bipartite, and directed acyclic graph.

References
ACM ICPC World Finals 2010 Problem Statement (n.d.). Available via internet:
http://icpc.baylor.edu/download/worldfinals/problems/2010WorldFinalProblemSet.pdf
ACM ICPC World Finals 2010 Solutions (n.d.). Available via internet:
http://www.csc.kth.se/~austrin/icpc/finals2010solutions.pdf
Bondy, J.A., Murty, U. S. R. (1976). Graph Theory with Applications, Vol. 290, London: Macmillan.
CEOI 2011 Solutions (n.d.). Available via internet:
http://ceoi.inf.elte.hu/probarch/11/ceoi2011booklet.pdf
CEOI 2011. Traffic Problem (n.d.), available via internet:
http://ceoi.inf.elte.hu/probarch/11/trazad.pdf
Cook, S.A. (1971). The complexity of theorem-proving procedures. In: Proceedings of the Third Annual ACM
Symposium on Theory of Computing. ACM, 151158.
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press.
Foriek, M. (2015). International olympiad in informatics 2015 syllabus. Available via internet:
https://people.ksp.sk/~misof/ioi-syllabus/ioi-syllabus.pdf
Gonthier, G. (2005). A computer-checked proof of the four colour theorem. Available via internet:
http://research.microsoft.com/en-us/people/gonthier/4colproof.pdf
Google Code Jam 2008 Round 1A, Milkshake Problem (n.d.). Available via internet:
https://code.google.com/codejam/contest/32016/dashboard#s=p1
Google Code Jam 2008 Round 1A, Milkshake solution (n.d.). Available via internet:
https://code.google.com/codejam/contest/32016/dashboard#s=a&a=1
Halim, S., Halim, F. (2013). Competitve Programming 3. lulu.com
IOI 2008, Island Problem (n.d.). Available via internet:
http://www.ioinformatics.org/locations/ioi08/contest/day1/islands.pdf
IOI 2014, Friend Problem (n.d.). Available via internet:
http://www.ioinformatics.org/locations/ioi14/contest/day2/friend/friend.pdf
West, D. B. etal. (2001). Introduction to Graph Theory, Vol. 2. Prentice hall Upper Saddle River.

98

J.I. Gunawan

J.I. Gunawan is an undergraduate student studying Computer Science


in National University of Singapore. He participated a lot of programming contests, including IOI 2012 and 2013 and ACM ICPC World
Finals 2014 and 2015. He is also the lead of the Scientific Committee
of Indonesian Computing Olympiad team (TOKI) training Indonesian
teams for IOI in 20152016.

Olympiads in Informatics, 2016, Vol. 10, 99109


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.07

99

Homo Informaticus
Why Computer Science Fundamentals are
an Unavoidable Part of Human Culture
and How to Teach Them
Juraj HROMKOVI
Department of Computer Science, ETH Zrich
e-mail: juraj.hromkovic@inf.ethz.ch

Abstract. The goal of this article is on one hand to introduce informatics as a scientific discipline
in the general context of science and to outline its relationships especially to mathematics and engineering, and on the other hand to propose a way how to integrate computer science into school
education.
Keywords: teaching, computer science, mathematics.

1. Introduction
The development of human society is mainly determined by the ability to derive knowledge and to find efficient ways of applying it. Let us explain this claim more carefully.
Human beings sample experiences by observations and experiments and use them to
generate knowledge by combining their experience with logical thinking. The derived
knowledge is used to develop procedures in order to reach concrete goals. A crucial point
in our considerations is that to use such procedures one usually does not need to fully
understand the knowledge used to obtain such procedures. To an even higher extent, one
does not need to understand the way in which this knowledge was derived and verified.
Let us illustrate this on a simple example.
The famous theorem of Pythagoras claims c2 = a2 + b2 in any right triangle, where
c is the length of the longest side (hypotenuse). This theorem was used to fix the right
angles when building houses and temples in the classical antiquity. The workers only
needed to build a triangle of sizes 5 units, 4 units, and 3 units in order to get a right
angle, and for sure they did not need to understand how the theorem of Pythago-

100

J. Hromkovi

ras was discovered and how it was proven. Hence, to successfully apply the derived
knowledge, one did not need to master the high qualification of an investigator. In this
way, scientists changed and still change society and became a crucial factor in human
development.
Computer science was created as a natural step forward in the above described development, when the following two conditions were satisfied:
1. Using the exact language of mathematics, one was able to discover and describe
procedures in such a way that no intellect was needed to apply them. Executing
them step by step, everything was unambiguous, and no educated or trained person was needed to find the right interpretation of the particular instructions of the
procedure executed.
2. The technology enabling to execute the discovered procedures by machines was
developed, and languages providing the opportunity to explain universal machines what they have to do were designed.
In this context, we speak about automation. We let the machine execute not only
physical work, but also such human work considered as intellectual work in the past.
This is the reason why computer science is a mixture of mathematics and engineering.
On the one hand, one uses the concepts, methods, and the language of mathematics in order to understand the considered entities and their relations so exactly that
algorithms as unambiguously interpretable procedures can be developed in order to
solve a variety of problems everywhere in science, technology, and everyday life. Here,
mathematics is the instrument that has to be mastered together with the specific area in
which one tries to solve problems.
On the other hand, developing and improving the enabling technology is mostly
engineering. This is not only about hardware, but especially about software enabling
us to conveniently communicate with computers in high-level programming languages.
We see that computer science is a part of the natural development of science, and
it became a discipline that is crucial for the performance of the human society. This
contextual view is important when thinking about what computer science actual is, and
how to teach computer science in schools. We are asked not to teach specific isolated
facts, methods, and other final products of scientific work, but the way how they were
discovered, i. e., the paths from the motivation coming from the general context of science to the final products of the research work and engineering. As in its fundamentals
computer science is very strongly related to mathematics as its basic research instrument, we start with the question What is mathematics and how to teach it? in the
next section, and use the derived point of view in the final section to propose the way
of teaching computer science in schools. Before the final section, however, we discuss
engineering as a missing subject in schools in Section 3. Again, we use this discussion
in order to show in the final section how teaching computer science can contribute to
understanding some basic concepts of engineering and how it integrates them in the
school curriculum.

Homo Informaticus. Why Computer Science Fundamentals are an ...

101

2. Mathematics as the Language of Science and Consequences


of this View for Teaching It
What is mathematics? If you pose this question, you can get a lot of different answers;
frequently, even the response that this question is too hard to be answered satisfactorily.
A mathematician or a university student can tell you with high probability that she or
he proves theorems and thus investigates the structure and the properties of artificial
mathematical objects, which can be useful to model reality, or the relationships between
different such objects. A high-school student can tell you that mathematics consists of
calculations that can be used to solve some classes of mathematical tasks (also called
problems) such as solving quadratic equations or systems of linear equations or analyzing the properties of a curve. Obviously, you can also get a response that mathematics
is something that is hard to understand, and that every normal human being can exist
and be successful without it. This is a frequent answer, and unfortunately it is more of a
rule than an exception.
Mathematics is the most powerful instrument humans ever have developed in order
to investigate the world around us. But it is taught in such a way that the students do
not realize this fact. Especially in high schools, they learn methods (algorithms) to solve
some given problems (for instance, to find a maximum of a function). This may be also
viewed positively as an intellectual challenge, because several methods are not easy to
manage. But the bad news is that they can learn to successfully apply methods for solving different problems without really understanding why these methods work properly.
High-school students often do not have a good intuition of what infinity or limits are
about, but they use these concepts in a fuzzy way in order to analyze artificial functions
without seeing any relation to reality. What are we doing wrong? A lot. We have to start
to think first about what mathematics is, and then to try to find a way how to teach mathematics in a proper way.
From my point of view, the best way to view mathematics is as a special language
developed for science, i. e., for knowledge generation. Going a few thousand years
back, people wanted to discover objective knowledge. The important word here is
the word objective. If you want to reach that, first of all you need a language in which
each statement has an unambiguous interpretation for everybody who mastered this
language. How to reach this? First of all, you need to give an absolutely exact meaning
to the words (notions) you use, because the words are semantically the corner stones of
each language. In this context, mathematicians speak about axioms. Many people have
the wrong impression that axioms are claims in whose truthfulness we believe, but of
which one is not able to prove that they are true. This is mostly not the case. Axioms
are the precise definitions of basic notions that describe our intuition about the meaning of these notions. Probably the first concepts people tried to fix were notions such as
number, equality, infinity, point, line, distance, etc. What is very important to observe is
that people needed hundreds and in some cases thousands of years to come up with such
definitions that the community of philosophers and later mathematicians has accepted.
Why was all of this done? First of all, the language of mathematics is able to describe

102

J. Hromkovi

objects, structures, properties, and relationships in an unambiguous way. In this context


we speak about the descriptional power of mathematics. Thus, people were able to
formulate exact claims this way, and so to express our knowledge unambiguously. But
this was only one side of the language of mathematics. The language of mathematics
was also used to derive new knowledge from the given knowledge, i. e., as a knowledge
generator. Leibniz formulated this role of mathematics in a very nice way. He wanted to
omit all political discussions and fighting in different committees by simply expressing
the real problems in the language of mathematics, and then using calculations and logical derivations to obtain the right solution. Interestingly, he called this automation
of the human work. By now we know that this dream of Leibniz cannot be achieved.
There are two reasons for that. First of all, because of its exactness, the language of
mathematics is restricted in its descriptional power, and so we cannot translate all realworld problems into this language. Secondly, one of the most important discoveries of
the last century made by Gdel tells us that the argumentational power of the language
of mathematics is smaller than its descriptional power. This means that one can formulate claims in current mathematics for which there do not exist proofs of whether they
are true or not.
What do scientists learn from that? The development of the language of mathematics is similar to the development of natural languages. You need to create new words
and describe their meaning in order to increase its descriptional power, and to be able
to speak about things you were not able to speak about before. Moreover, you need new
concepts and words to be able to argue about matters you were not able to argue before,
i. e., in order to strengthen your capability of deriving new knowledge by thinking. A
very important point is that the process of developing the language of mathematics is
infinite. As long the number of basic, axiomatic words of the language of mathematics
is finite, one can always formulate claims that are not provable within this mathematical
language, and one has to introduce new words in order to be able to prove them and so
to make new discoveries.
A very nice example is the notion of infinity. Nobody saw anything infinite in the
real world, and even most physicists believe that the universe is finite. This means that
infinity is something artificial, simply an artificial product of mathematics. But without
this concept, most of the current science would not exist. Without the notion of infinity,
there would be no concept of limits and so we would not be able to exactly express notions like actual speed or actual acceleration. Our science simply would be somewhere
before the discoveries of Newton. Hence, without the artificial concept of infinity,
one is strongly restricted in the ability to discover our finite, real world.
Another example of a crucial notion is the concept of probability. Most of the sciences, even the non-exact ones such as didactics, psychology, medicine, and economy,
heavily use this concept to model and investigate reality, and if they would make predictions without this concept, they would have serious trouble to convince society that their
results are trustable to some extent and not only expert opinions.
Why did we focus on the view of mathematics presented above? Because it is the
nature of mathematics that shows us which changes are necessary in order to improve

Homo Informaticus. Why Computer Science Fundamentals are an ...

103

the education in mathematics for everybody. Based on this, we recommend to adopt the
following concepts:
1. Focus more on the genesis of the fundamental notions (concepts) of mathematics.
To define them took centuries, to prove most of the theorems took a few years.
Each new concept enabled to investigate so many things that no single discovery
can compete with introducing a fundamental concept. The strengthening of mathematics as a research instrument is the main job of mathematics, and deriving
new concepts (not necessarily on the axiomatic level) in mathematics provides
the best, true picture of its nature. Without this, nobody can really understand its
role and usefulness. And only if one understands the genesis of mathematics as
the development of a language of science and as a research instrument, one can be
able to apply it regularly to all areas of our life. Teaching mathematics this way
can completely change the behaviour of the members of our society. Instead of
memorizing and sampling facts provided, one would start to verify the degree of
trustability of claims sold as knowledge and to understand to which extent and
under which conditions one is allowed to take them seriously.
2. Concrete examples first, abstraction as a final discovery. One first has to touch
concrete problem instances and objects in order to get some intuition about their
properties. Then, one can formalize her or his intuition into a formal concept.
One has to follow the natural way of discovering that usually goes from concrete
to abstract. To sell methods and theorems as final products is as poor as teaching
manuals for washing machines or Microsoft office instead of teaching discoveries of physics, mechanics, and computer science that enabled to develop these
products.
3. Teach algorithmics instead of training calculation methods. Pupils learn in schools
to multiply arbitrarily large integers in decimal representations, to solve quadratic
equations and systems of linear equations, or to analyze functions, etc. In all cases, most pupils learn to apply given methods, but most of them do not understand
why they work. It is more of a challenging memorizing than a deep understanding
of the nature of the algorithms used. One has to start to introduce problems instead
of presenting methods solving them, and ask the pupils and students to solve concrete problem instances first and finally to discover an algorithm as a robust procedure that is able to solve any of the infinitely many concrete problem instances
of the given problem. Discovering algorithms as well-functioning calculation procedures offers another quality of education in mathematics than executing a given
calculation method, which any pocket calculator can do faster and more reliable.
Teach programming as the art of exactly describing the methods discovered in an
unambiguously interpretable way in the language of the machines, and strengthen
the ability of exact communication this way.
4. Teach the principles of correct argumentation. Teach the notions of implication
and quantifiers, and train direct and indirect proofs. Do not believe that the pupils
in high schools cannot learn to verify and to derive simple proofs. They did not
manage this in the past, because there was no effort made to teach proving claims,
or most effort in this direction was done in a wrong way.

104

J. Hromkovi

5. Guarantee the opportunity to the pupils to deal with the subjects as many time as
needed at an individual speed. Mathematics is one of the sciences that needs a
large number of iterative touchings of particular topics until one is allowed to say
Eureka, and gets a reasonable understanding of what it is about. The trouble is
that no teacher can assure this by herself or himself for everybody in the class.
Another problem is that most textbooks of mathematics are good collections of
exercises, but explanations are written more for teachers than for pupils. One way
out is to change the style of the textbooks. The textbooks should be written in
such a way that pupils and students would be able to learn from them by their own
with a minimal support from outside. Partitioning the discoveries into a number
of small, natural steps written in the language mastered by the pupils at the corresponding age, and regularly giving the opportunity to verify whether one understands the topic up to now properly are some of the basic principles used to create
good textbooks for mathematics.
Finally, one can ask how to reach the new teaching style for mathematics described
above. For sure, one cannot ask the high-school teachers to make this change without
showing them how to do this in detail. One also cannot ask educationalists, who do not
have a sufficiently deep contextual knowledge of mathematics to master these changes.
The movement has to start at the universities, where the teaching style has to change
first. In order to speed up this process in Switzerland, in our department at ETH Zrich
we develop new textbooks for teaching different topics of mathematics and computer
science for all school levels. Our experiments prove that mathematics can become one
of the most favorite subjects of pupils and students if taught in the way described
above. Students can successfully master topics that were considered to be too hard for
them before, and the marks in mathematics can be significantly higher than the average
marks over all topics.
For me, it is not a question of whether the proposed evolution of the education in
mathematics will come. It is only the question of the time at which particular countries
will need to adopt it. Since this is a service for the future generation, the earlier the
better.

3. Why Engineering is Not Allowed Not to Be a Part of Basic Education


As mentioned in the introduction, human society uses the knowledge discovered in order
to reach different goals more efficiently by developing various procedures or different
products. This is highly creative work that is beyond the pure learning of facts and making calculations that can be completely automatized. The whole process of engineering
work starts with a description of the goals to be achieved. After that, one starts to combine experience and fundamental knowledge of science in order to design a solution that
has to be implemented as a prototype. Next, one has to test this prototype, modify, and
improve it until an acceptable product is produced.

Homo Informaticus. Why Computer Science Fundamentals are an ...

105

In todays schools, we find almost nothing about the concept of iterative specifying,
testing, modifying, and improving the product of our work, let alone about fundamental
constructive ways of creating original products. But this is fundamental to human activities since the beginning of time. The current school systems ignore this fact to a high
extent and are more about teaching to memorize than teaching to work in a creative
way. One can explain this educational misconception by the fact that, in contrast to
basic scientific models of reality, the engineering work is heavily dependent on experience that is often hard to formalize and thus to teach. The creative work of engineers
as human experts cannot be described by an algorithm (a method). However, this must
not be a reason to remove engineering from education, because students also have to
learn to build their own experience over a longer period of time in order to become an
expert for a special area.
The crucial fact we want to point out is that computer science mastered to formalize
several basic concepts of engineering and made them available to our schools as a result.
Teaching computer science is a chance to introduce engineering as a highly creative,
constructive activity to our educational system.
Let us consider some concrete illustrations. Probably the most fundamental concept of technical sciences is modularity. One builds some simple units with clear and
well verifiable functionalities and calls them modules. Then one uses these modules
as fundamental building blocks to construct more complex systems that are again
considered basic modules for constructing even more complex systems. There is no
upper bound on the growth of the complexity of systems built in such a way. Unbelievably many human activities can be described by this modular concept. This
includes learning. Ones learns some simple facts and methods and their applications
in a restricted framework. After that, one masters them perfectly in such a way that
one can use them as elementary operations in attacking more complex tasks. All spiral
curricula run in a well-designed modular way. Thinking in a modular way when trying to reach given goals is the most fundamental instrument of creative human work.
And it does not matter whether you apply it top-down or bottom-up. If one applies a
top-down approach, then everything is clear and one designs only a transparent and
well-verifiable plan for constructive work. More typical is the bottom-up approach
where one builds more and more complex modules without knowing what the final
product will be about.
Programming is an excellent instrument to teach modularity. Writing programs to
automate solving different tasks provides modules for attacking much more complex
tasks. Children of age between 10 and 12 are able to put five loops into each other without being disturbed by or even observing the complexity of their final product due to
modularity. One simple program containing a loop gets a name and so becomes a new
instruction. This instruction is used in the body of another loop that also becomes a new
instruction used in another loop, etc. Here, one can train both, the top-down approach as
well as bottom-up approaches devoted to open-end tasks. To practice the ability to bring
a clear structure into complex processes is at least as important as any of the fundamental concepts of sciences or humanities contained in the school curricula.

106

J. Hromkovi

Another important concept is teaching to test or verify products of our work. Typically, children verify their own products by asking teachers or adults to tell them whether
their work resulted in what they were asked to reach. But this way, they cannot sufficiently build their self-confidence because they need a strong dependency on their supervisor. They have to learn to trust their solutions by being taught to verify the products of
their work by themselves. Programming is again a wonderful instrument for this purpose
using the platform or editor that fits the educational requirements. One can learn to test
the functionality of programs by running them on several data sets as well as by the verification approach based on a transparent structuring of the program into small modules
whose correct behavior can by easily verified.
In general, constructive engineering work within the educational system changes the
behavior of young people in an essential way. They move from the role of customers
searching for products with some desired property to the role of creative inventors for
designing and developing products with new, original functionalities. The never-ending
story of improving any human products with no limits on what can be approached in the
future would be the most important, great consequence of embedding the creative way
of thinking of engineers into school systems.

4. Teaching Computer Science as a Fundamental Step in the Evolution


of Our Educational Systems
In the two previous sections, we already outlined, with respect to improving teaching
of mathematics and introducing engineering, the principal contributions that could be
offered by teaching computer science in schools in a proper way. This word proper is
crucial for us, and thus we start by listing what we are not allowed to do if we want to
avoid a disaster when introducing computer science to schools. In what follows, we present the most frequent mistakes that already caused frustrations in different countries.
1. To teach how to work with concrete software products and call it computer science. This activity destroyed the image of computer science as a scientific discipline in the past.
2. To let computer science be taught as a part of social media by teachers educated
in human sciences only, and focusing on social, emotional and psychological aspects of communication by new technologies.
3. To choose the topic to be taught by committees of experts offering their favorite
topic without looking at the whole context of science as presented above in Section 2.
4. To sell computer science as the ability to work with computers.
5. To sell computer science as a special branch of mathematics.
6. To sell computer science as a pure engineering discipline.
7. To try to teach the newest achievements of computer science. Think about what
would happen if physics would try to do that instead of following the history, and
thus developing step by step our view of the physical world.

Homo Informaticus. Why Computer Science Fundamentals are an ...

107

8. To try to sell computer science as a joy much easier than mathematics and physics
by avoiding any depth and thus a spiral curriculum, and instead presenting one
simple application after the other.
9. Going too much into technical details about concrete programming languages,
software systems, or hardware.
While 1, 2, and 4 have been the main reasons for destroying the image of computer
science in the society in the past, currently the points 7 and 8 are the major danger for
establishing computer science as a school subject.
After listing what we are not allowed to do, it is now time to switch to positive
recommendations and conceptual work. We do not want to make a proposal for the
content of a computer science curriculum, because our goal is not to go too much into
detail, and because, for sure, there are various possibilities for good implementations of
the computer science subject in schools. What we try here is to recommend a strategy
and principles that are useful for designing a computer science curriculum that can be
accepted as a fundamental part of education in its generality for everybody, and that essentially contributes to:
1. The understanding of our world (in this case with the focus on the artificial world
created by humans).
2. Developing our way of thinking in a dimension that cannot be compensated by
teaching other school subjects.
3. Providing knowledge that is useful and sometimes even expected as prior knowledge for the study of a variety of specialized scientific disciplines later (university
studies, etc.).
As a byproduct, we have to aim to improve teaching overall, especially by strengthening the subjects mathematics and natural sciences. We already presented the basic
strategy how to design a computer science curriculum in Section 2 about mathematics.
We have to follow the genesis of computer science and think about motivations and
fundamental concepts introduced and discovered by computer scientists from the point
of view of science as a whole. For sure, we have to think about or even discover which
concepts are available to which extent in which age, and to follow all the ideas for creating good teaching materials as presented in Section 2. Let us be more concrete and
present a few examples.
One can decide to introduce programming at the age between 8 and 14. The first
step is to deal with abstractions that enable us to unambiguously describe the problem
instances. Then we teach to sample experience by trying to find solutions to concrete,
special problem instances, whose size and complexity may grow with growing experience. After some time, one can develop a strategy that works successfully for a small
collection of problem instances that we subsequently call a problem. Having a solution
strategy, one has to learn to communicate it, i. e., to unambiguously describe it for anybody else. After that, we are allowed to start teaching proper programming by describing
our strategy as a program in a suitable programming language. We are not allowed to
teach the list of all instructions (fundamental words) of a programming language. We
have to start with very few (10 to 15) fundamental instructions, and use modularity to

108

J. Hromkovi

create new words (instructions) in order to make our communication with the computer
more convenient. After writing programs, we let them run in order to verify their correct functionality and learn to correct, improve, and modify our programs in order to get
a final product with which we are satisfied. Let us list some of the added values when
teaching the introduction to programming in the way described above:
1. Training and strengthening the abstraction in representing real situations by drawing graphs, writing lists or tables with different kinds of elements.
2. Contributing to teaching mathematics by searching for a solving strategy, instead
of simply learning a method as a given product of the work of others.
3. Strengthening the ability to express matters and procedures in an exact way, and
so to improve the way used to communicate.
4. Recognizing that a language is not a given final product of human work, but that
any language is continuously developed, and that in case of a programming language one can develop the language on her or his own with respect to her or his
personal demand.
5. Defining new instructions by describing the meaning of the new words by subprograms, one learns the principle of a modular design that is common and fundamental in engineering.
6. Introducing the concepts of testing, verifying, modifying, and improving is the
first contact with the creative, constructive work of engineers.
A really good teaching sequence for introductory programming can be created if one
focuses on the above listed added values and not on technical details of programming
languages and other software used or on a specific class of tasks.
Another nice example is teaching cryptography. Cryptography can be viewed as
the history of developing the notion secure cryptosystem. One can start with the
historical examples in order to introduce the basic terms decryption, encryption, key,
and cryptosystem with a lot of creative work by designing and breaking new, own
cryptosystems. After defining the concept of security by Kerckhoff, one can build
the bridge to probability theory. The concept of probability was used to design new
cryptosystems and later to break them. One can wonderfully understand the importance and the usefulness of the concept of probability studying the history of secret
communication in this way. Then one can introduce the formal mathematical definition of absolutely secure cryptosystems with respect to the concept of probability, and
recognize that such system cannot be built for practical purposes. Finally, the concept
of computational complexity offering public-key cryptosystems is the way out, leading
to the recent e-commerce.
What we try to repeatedly present as the key strategy is to follow the history of the
discoveries of particular concepts, methods, and ideas, and not to try to sell finalized
products of science. The creative work is the most (and may be even the only really)
exciting part of the study. Let us teach creativity by repeatedly discovering things that
were already discovered, up to the point where one is able to discover something completely new. Forget about teaching facts, teach how to verify the trustability of claims
made by others. We are lucky, because we are allowed to create a curriculum for a

Homo Informaticus. Why Computer Science Fundamentals are an ...

109

completely new subject. We can implement principles, which the other subjects still
did not recognize, and so contribute to the evolution of the system of education. For
those who would like to see detailed implementations of the design principles presented
above, we recommend to following textbooks from our production (Bckenhauer and
Hromkovi, 2013; Freiermuth et al., 2014; Hromkovi, 2011; Hromkovi, 2014) or
the book Algorithmic Adventures from Knowledge to Magic (Hromkovi, 2008;
Hromkovi, 2009).

References
Bckenhauer, H.-J., Hromkovi, J. (2013). Formale Sprachen. Springer Vieweg.
Freiermuth, K., Hromkovi, J., Keller, L., Steffen, B. (2014). Einfhrung in die Kryptologie. 2nd Edition.
Springer Vieweg.
Hromkovi, J. (2011). Berechenbarkeit. Vieweg+Teubner.
Hromkovi, J. (2008). Sieben Wunder der Informatik Eine Reise an die Grenze des Machbaren.
Vieweg+Teubner.
Hromkovi, J. (2009). Algorithmic Adventures From Knowledge to Magic. Springer.
Hromkovi, J. (2014). Einfhrung in die Programmierung mit LOGO. 3rd Edition. Springer Vieweg.

J. Hromkovi is professor of informatics with a special added focus on computer science education at ETH Zurich. He is author of
about 15 books published in 6 languages (English, German, Russian,
Spanish, Japanese, and Slovak) and about 200 research articles. He is
member of Academia Europaea and the Slovak Academic Society.

Olympiads in Informatics, 2016, Vol. 10, 111124


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.08

111

Examples of Algorithmic Thinking in


Programming Education
Juraj Hromkovi, Tobias Kohn, Dennis Komm, Giovanni Serafini
Department of Computer Science, ETH Zrich
Universittstrasse 6, 8092 Zrich, Switzerland
e-mail: {juraj.hromkovic, tobias.kohn, dennis.komm, giovanni.serafini}@inf.ethz.ch
Abstract. Algorithmic thinking and problem solving strategies are essential principles of computer science. Programming education should reflect this and emphasize different aspects of these
principles rather than syntactical details of a concrete programming language. In this paper, we
identify three major aspects of algorithmic thinking as objectives of our curricula: the notion of a
formal language to express algorithms, abstraction and automation to transfer proven strategies to
new instances, and the limits of practical computability.
The primary contribution of this paper are three examples that illustrate how general aspects
of algorithmic thinking can be incorporated into programming classes. The examples are taken
from our teaching materials for K-12 and university non-majors and have been extensively tested
in the field.
Keywords: algorithmic thinking, K-12, spiral curriculum, programming education, Logo, Python.

1. Introduction
Algorithmic thinking constitutes one of the core concepts of computer science. It has
proven a versatile and indispensable tool for problem solving and found applications far
beyond science. Hence, sustainable computer science education should be built upon
algorithmic thinking as its primary objective, thus unfolding benefits for a broad and
general education. However, how do we bring algorithmic thinking to computer science
education? In this paper, we identify a number of principles that we want to deliver to
students at different levels. As the main contribution, we describe concrete examples of
how to teach these paradigms, which have been proven successful in the past.
Our work is part of ubiquitous efforts towards establishing sustainable computer science
in K-12 education. Particularly noteworthy and inspiring are CS unplugged approaches
as proposed by Bell etal. or Gallenbacher, which do completely away with computers
and solely focus on the underlying algorithmic principles (Bell et al., 2012; Gallenbacher,
2008). By incorporating such ideas into programming education, we effectively combine
the strengths of the two approaches, resulting in a truly sustainable education.

112

J. Hromkovi et al.

1.1. The Setting


The examples presented in this paper stem from teaching materials we have developed
for primary school, high school, and university, respectively (Gebauer et al., 2016;
Bckenhauer et al., 2015a; Bckenhauer et al., 2015b; Kohn, 2016). The goal of our
endeavours is to create a spiral curriculum that starts as early as fifth grade in primary
school with iterations throughout mandatory school, and including computer science
classes for non-majors at university level.
We use both Logo and Python in our classes and found that the simplicity of Logo
is especially well-suited for primary school and complete beginners. At high school
and university level, Python then allows us to discuss topics in more depth and to better
link our programming classes to mathematics and the sciences. We have also extended
our Python interpreter and included Logos repeat-loop into Python. This allows us
to introduce iteration at an early stage without the need for variables, getting the best
of both worlds.
Our curricula and examples make heavy use of turtle graphics, both in Logo as well
as in Python. Apart from the obvious benefits of direct visualization, the turtle is also a
source of powerful didactical metaphors. In particular, the examples as presented in this
paper all rely on turtle graphics to convey or visualize an algorithmic principle.

1.2. Objectives
Computer science is a vast field with algorithmic thinking at its core. Our curricula
hence focus on the study of algorithms and its various aspects. Our approach comprises
three major aspects of algorithmic thinking, as described in the following paragraphs:
the notion of the programming language as a formal language to express algorithms, abstraction and automation as central problem solving strategies, and the limits of practical
computability as a motivation for improving existing algorithms. More on the authors
goals, motivation, and approaches can be found in a complementing paper (Hromkovi
etal., 2016).
Concept of a Formal Language. Students are introduced to programming as a means to
convey instructions to a machine in our case the turtle. The initial set of instructions is
strongly limited and restricted to basic movements such as moving forward and turning.
Each instruction has a clearly defined syntax and semantics, avoiding any ambiguity.
At first, then, programming is the activity of writing sequences of such instructions, encoding graphical shapes. From our perspective, this is to say that students use a formal
language to combine words to sentences. Even though each valid sentence conveys the
information of a graphical shape, not every sentence makes sense in the context of the
interpretation of the resulting shape.
The initial vocabulary given to the students is not adequate to encode more complex
shapes in a human-accessible form. Students are early required to extend the vocabulary
by defining new words, i. e., by defining subroutines. In the context of the turtle, this can

Examples of Algorithmic Thinking in Programming Education

113

Fig. 1. By parametrizing programs, we gradually gain more versatile algorithms and procedures. Drawing a square of fixed size is the first step towards drawing arbitrary polygons of
various sizes (above). Likewise, loops allow us to build ever more complex and larger programs out of simple and small parts (below).

be beautifully explained as teaching the turtle new words (Papert, 1993). The semantics of the new words is expressed algorithmically as a sentence over an already existing
vocabulary. Think, for instance, of a house consisting of a triangle and a square. Both
the triangle and the square themselves might be expressed as sequences of forward- and
turning-instructions.
Hence, our objective is to provide students with a simple yet expandable base of
instructions, the means to combine these instructions to sentences, and to define new
words with associated unambiguous semantics. This way, the students are exposed to
the concepts of modularization, formal languages, and expressing semantics in algorithmic form.
Abstraction and Automation. Programming is, of course, much more than combining
instructions to form programs. Some of the most essential key concepts are abstraction
and automation. Modularization, for instance, only unfolds its full potential in combination with parameters. Having a dedicated instruction to draw a square, say, helps to
clarify the intent of a program. Allowing that very same instruction to draw squares of
various sizes makes it versatile and open to applications beyond its initial conception.
Further abstraction could even introduce a second parameter to pertain to the number
of vertices to draw, resulting in one instruction capable of drawing all regular polygons
(see Fig. 1).
Abstraction itself also requires the concept of automation. Even drawing a regular
polygon with a given number of vertices is a tedious task without the notion of a loop.
For the step to an abstract instruction encompassing all polygons, the loop becomes a necessity. Once this level of automation is mastered, students are introduced to loops with
variations, allowing for figures such as spirals where even the parameter automatically
varies (see Fig. 1).
Automation and abstraction are not just core concepts of programming but of computer science and algorithmic thinking in a much wider sense. Expressed in the context
of problem solving, abstraction corresponds to the question Can we adapt an already
known or universally available strategy to solve the problem at hand? Once we know
how to solve a single instance, we then employ the concept of automation to apply our
solution to a large set of instances.

114

J. Hromkovi et al.

Limits of Practical Computability. Finding solutions automatically is not always


feasible. Indeed, the insight that there are problems that cannot be solved algorithmically (i.e., undecidable problems), shown in 1936 by Turing in his seminal paper On
Computable Numbers, with an Application to the Entscheidungsproblem (Turing,
1936), is one of the deepest results of mathematics and laid the foundation for computer science itself. However, even computable problems can often only be solved
under certain restrictions, e. g., using an unacceptable amount of resources (time and
space), or without full precision due to numeric errors. This gives rise to numerous
interesting research questions and solutions, which can both be explained to nonprofessionals.
For education, however, we need to make computability and its limitations visible
and tangible. A prime example to serve this objective, as taken from turtle graphics,
are circles. A computer cannot draw an exact circle, it must be drawn using an approximation such as a polygon (or Bzier curve). The cost of drawing an approximating polygon increases with the number of vertices, mainly due to the fact that the
turtle needs time to turn at the vertices. Students therefore must find a compromise
between more accurate representations and faster renderings, and eventually realize
that the limitations of screen resolution quickly nullify additional precision beyond a
certain point.
When seen in the light of modern applications, intractability is of particular importance to cryptography. In this regard, the inability to design efficient algorithms has
far-reaching implications beyond computer science and its inclusion into the curriculum
is well-warranted. At the same time, we found cryptography to be very motivating and
well-suited as a subject of its own (Freiermuth etal., 2010).

2. Modular Development: Building a Town Step by Step


Our group is actively involved in introducing young students to programming as soon
as at fifth grade. To this end, we developed teaching material, hold classes, and, most
importantly, introduce teachers to our didactic approach as well as to fundamental
concepts of computer science. These school projects are based on the German textbook An introduction to programming in Logo (Hromkovi, 2014, German: Einfhrung in die Programmierung mit Logo), and on a Logo booklet (Gebauer etal., 2016)
covering the contents of its first seven chapters. The following example is taken from
this booklet.
As already mentioned, one of the main objectives of our programming classes consists in making the students confident with the modular development of programs and
teaching them how to systematically apply this problem solving strategy to complex
problems. To illustrate our approach and the achievements of the students, we present
a sequence of learning activities from the third (out of seven) unit of the courses.
At this point, the students already know how to move the turtle forward and backward on a straight line, how to rotate it as well as how to iterate over a sequence of

Examples of Algorithmic Thinking in Programming Education

115

instructions for a predefined number of times. More precisely, the current vocabulary of
the turtle comprises the following instructions as well as their abbreviations: forward
(fd), back (bk), left (lt), right (rt), clearscreen (cs), penup (pu), pendown
(pd), and repeat. Furthermore, the students are already used to giving their programs
names and to reusing available programs as subprograms within main programs in an
elementary way. In subsequent activities, they learn how to develop a table that consists
of rows of identical squares in a proper modular way.
To reinforce the concept of modular development, the students are now challenged
to write a program for drawing a small town, which consists of streets with identical
houses. While the program for drawing a house is already available in the booklet, the
students are expected to consequently apply the approach they intensively practiced.
They are therefore expected to:
Identify the next shape or pattern they can systematically reuse.
Write a sequence of instructions for drawing it.
Give this subprogram a name.
Test and iteratively improve the code until the solution meets the assignment.
Afterwards, the students should reflect on how to adjust the position of the turtle in
order to draw the pattern by simply reusing the program they developed above, to test
and to iteratively improve their approach, and to finally integrate the two modules of
their solution. In a following step, this new main program can be reused as a subprogram in other main programs of increased complexity. More specifically, the students are
given the program shown in Listing 1.1 accompanied by the following exercise, which
asks them to study the effects of each command in detail.
Exercise. Where does the turtle start drawing the house? Think about the path the
turtle follows when drawing the house using the program HOUSE. Where is the
turtle located at the end of the execution? Draw the image and describe the effect
of each command.
Next, they are told how to design a program HOUSEROW (Listing 1.2) that uses HOUSE
as a subprogram. Here, the most difficult task is to position the turtle in such a way that,
after each iteration, the new house is drawn at the correct coordinates.
Listing 1.1: Drawing a house using a simple repeat-loop.

to HOUSE
rt 90
repeat 4 [fd 50 rt 90]
lt 60 fd 50 rt 120 fd 50 lt 150
end
Listing 1.2: Drawing a row of houses.

to HOUSEROW
repeat 5 [HOUSE rt 90 pu fd 50 lt 90 pd]
end

116

J. Hromkovi et al.

A small
townthat
that consists
of 15
Fig. 2:Fig.
A 2.small
town
consists
ofhouses.
15 houses.

At this
theare
students
already
how approach
to move the
turtletoforward
and
Finally,
the point,
students
asked to
use theknow
modular
in order
draw the
town
a straight
line,This
howway,
to rotate
it as well
howtoto
iterate
a
thatbackward
consists ofon
multiple
streets.
the students
learnashow
extend
theover
language
sequence
of instructions
a predened
number
of times.
precisely,
the is
of the
computer
step by stepfor
with
more complex
programs.
TheMore
crucial
observation
vocabulary
of the
turtle comprises
the subprograms.
following instructions as well as
thatcurrent
the overall
complexity
is hidden
in the smaller
their abbreviation: forward (fd), back (bk), left (lt), right (rt), clearscreen
(cs),
penup (pu),
pendown
(pd),would
and repeat.
Furthermore,
the students
are by
Exercise.
At this
point, we
like to extend
the complex
of buildings
already
used
to
giving
their
programs
names
and
to
reusing
available
programs
additional streets. Use the program HOUSEROW as a building block to draw the
as subprograms within main programs in an elementary way. In subsequent
image shown in Fig. 2.
activities, they learn how to develop a table that consists of rows of identical
Hint:inAfter
the completion
of a row, the turtle has to be moved to the correct posisquares
a proper
modular way.
To reinforce
thenext
concept
tion
to build the
street.of modular development, the students are now
challenged to write a program for drawing a small town, which consists of streets
Modular
development
offersthe
a didactically
creative
tasks. In
with identical
houses. While
program forappealing
drawing aplatform
house is for
already
available
in the
booklet,exercises,
the students
are expected
tothat
consequently
thesuch
approach
the two
following
the students
observe
even smallapply
changes
as adding
they intensively
are houses
therefore
expected
a window,
a door, orpracticed.
a chimneyThey
to their
may
have a to:
considerable impact on the

overall
outcomethe
of the
streets
townthey
theycan
are systematically
designing.
identify
next
shapeand
or the
pattern
reuse,

write a sequence of instructions for drawing it,


Exercise. We decide to order the roof for the houses from another vendor. That
give this subprogram a name, and
weand
getiteratively
two types improve
of building
Onethe
called
ROOFmeets
and the
another
one called
is,
test
the blocks:
code until
solution
assignment.

BASE. Write two programs to draw the two building blocks. Combine those proAfterwards,
thea new
students
should
reectthat
on how
to aadjust
grams
to form
program
HOUSE1
draws
house.the position of the

turtle in order to draw the pattern by simply reusing the program they developed
above,
to testThe
andhouses
to iteratively
improve
their
andtotobenally
integrate
Exercise.
in Listing
1.1 are
veryapproach,
simple. Try
creative
and come
the up
two
modules
of
their
solution.
In
a
following
step,
this
new
main
with a new design for a house. Use your house to build an entireprogram
complex of
can be reused as a subprogram in other main programs of increased complexity.
buildings.
More specically, the students are given the program shown in Listing 1.1
accompanied
by thethat
following
which is
asks
them to study
the eects
of
The
students learn
modularexercise,
development
a systematic
and efficient
problem
each command in detail.

solving strategy. Moreover, they experience that subsequent changes in a basic module
of a properly developed complex program require no or very limited additional program5
ming effort.

Examples of Algorithmic Thinking in Programming Education

117

3. Making Approximation Errors Visible with the Pac-Man


The turtle draws a circle by approximation, actually drawing a polygon with, say, 36 vertices (in practice, students often choose 360 vertices at first, building upon their knowledge that 360 stands for a complete circle). While the resulting figure is not discernible
from a true circle on the screen, the approximation requires a couple of corrections when
the circle is combined with other shapes. Most prominent is the question of finding the
circles center and the correct value of the radius. Both are slightly, but discernibly, off
compared to a true mathematical circle.
A particularly illuminating example is drawing a Pac-Man shape. Students are asked
to write a Python program that draws a Pac-Man and typically end up with a solution as
shown in Listing 1.3 (note that the repeat-loop shown here has been added to Python in
order to support our curriculum. A further discussion can be found in the aforementioned
complementing paper (Hromkovi etal., 2016)). However, their resulting pictures show
that the shape is not closed as seen in Fig. 3: there is a small gap at the center of the
shape. This discrepancy is subsequently discussed in a dedicated section and leads to a
precise drawing of a pie chart.
Why does this gap in the center occur and how can we correct it? In a circle, any radius meets the circumference perpendicularly. This fact has been used twice in the program (Listing 1.3). For the approximation with a polygon, this does not hold anymore:
the angle between the radius leading to a vertex and the circumference requires a small
correction (Fig. 4). The correction is exactly half of the turtles turning angle at each
vertex. For our example with 36 vertices, this results in a 5-correction (Listing 1.4). The
correction of the angle can also be taken into the loop, resulting in a more symmetrical
solution (Listing 1.5).
Listing 1.3: Drawing a Pac-Man.

from turtle import *


RADIUS = 100
right(45)
forward(RADIUS)
left(90)
repeat 27:
forward(RADIUS * 3.1416 * 2 / 36)
left(10)
left(90)
forward(RADIUS)

Listing 1.4: Correcting the angle (1).

left(90 + 5)
repeat 27:
forward(RADIUS * 3.1416 * 2 / 36)
left(10)
left(90 - 5)

118

J. Hromkovi et al.

Fig. 3. An incomplete Pac-Man.

Fig. 4. As circles are approximated by polygons the radius does not


meet the circumference in a right angle but is off by an angle .
Listing 1.5: Correcting the angle (2).

repeat 27:
left(5)
forward(RADIUS * 3.1416 * 2 / 36)
left(5)
Listing 1.6: Starting the circumference not at a vertex but at the center of an edge instead.

repeat 27:
forward(RADIUS * 3.15 / 36)
left(10)
forward(RADIUS * 3.15 / 36)

Finally, an alternative solution is to have the radius meet the circumference not at a
vertex but at the center point of an edge. In this case, the radius does meet the circumference perpendicularly. The resulting code, again, has a very symmetrical form (Listing
1.6). Yet the ratio between radius and circumference now differs and requires to change
the used approximation of the value of .

4. Runtime Analysis Backed up by a Little Math


One of the authors is currently part of the team responsible at ETH Zurich for teaching
computer science basics to non-computer science students (more specifically, students
of biology, pharmacology, environmental sciences, health sciences and technology, agriculture, geology, and nutritional sciences).
We have been introducing students to Logo using the previously mentioned booklet
(Gebauer etal., 2016, see Section 2), whose main part is covered in roughly the first unit

Examples of Algorithmic Thinking in Programming Education

119

Listing 1.7: A simple square.

to QUAD :WIDTH
repeat 4 [fd :WIDTH rt 90]
end
Listing 1.8: Testing whether a given number is prime.

to PRIME :NUM
ht
make "IT 2
make "ISPRIME 1
while [:IT<:NUM] [
make "RES mod :NUM :IT
if :RES=0 [make "ISPRIME 0] []
make "IT :IT+1
]

if :ISPRIME=1 [setpc 1 QUAD 8] [setpc 0 QUAD 8]


end

of the lecture. After that, an advanced booklet is supplied that is specifically designed for
this class (Bckenhauer etal., 2015a). As part of this booklet, more involved concepts
such as variables, conditional execution, and while-loops are introduced. The students
are then given three projects, which consolidate what they have learned so far by designing small programs to solve specific tasks (Bckenhauer etal., 2015b). The lecture is
accompanied by exercise classes in which the students are asked to present and explain
their solutions to a tutor.
As a first step towards the mathematical analysis of algorithms, we give the students
the following project. The examples are taken from the project booklet (Bckenhauer
etal., 2015b) and the corresponding lecture notes. The goal is to show the students the
idea of how to mathematically analyze how long a program will run depending on the
input size. A typical example that does not need anything beyond high school mathematics is to test whether a given number is prime. Logo is especially suited to visualize the
distribution of (small) prime numbers without much overhead.
The first component is a program called QUAD (Listing 1.7) that draws a square, and
which essentially consists of a simple loop, which the students already know from previous lessons. The size of the square is determined by the value of the parameter :WIDTH.
Next, we can write a program that tests whether a given input is a prime number.
This is done in the most straightforward fashion, i. e., by testing whether there is smaller
number (except 1) that divides it. Depending on the result, either a red or black square is
drawn on the screen using the instruction setpencolor (setpc). Before that, the turtle
is hidden with the instruction hideturtle (ht). The corresponding algorithm PRIME
is shown in Listing 1.8.
The students can easily follow the steps and try out different inputs. As a next step,
we ask them to carefully check corner cases, and give them the following exercise.

120

J. Hromkovi et al.

Exercise. PRIME does not yet work correctly on all inputs as the value of :IT is
initially set to 2. However, we know that 1 is by definition not a prime number.
Thus, PRIME 1 creates an incorrect output. Extend the program such that a black
square is drawn when the input is 1. Moreover, an error message should be output
if 0 or a negative number is given.
Once the students familiarized themselves with the algorithm, we discuss its running
time. It is obvious that the time grows with larger inputs, and this seems to be unavoidable on an intuitive level. Furthermore, it is easy to see that the running time directly
depends on how often the body of the while-loop has been executed. We therefore agree
on counting the number of these executions and neglect how many instructions are executed with each iteration. The above trivial attempt needs roughly 2 iterations for inputs
of length (hence, is the number of bits used to represent the input number). Now we
show how to improve this running time using a little bit of math. The following exercise
is well-suited to be presented to the students as part of the lecture.
Exercise. We can now make our algorithm PRIME faster (more efficient) by
having it execute the while-loop less often. To this end, we make use of the
following idea.
Suppose the input is not a prime number. Then, by the definition of a prime
number, there is a number , which is neither 1 nor , that divides without
remainder. But from this it also follows that there is a second number , which
is also neither 1 nor , that also divides without any remainder. An important
point is that one of these two numbers is not larger than the square root of.
If, e. g., is larger than , then has to be smaller, since otherwise were
larger than .
We want to use this observation to improve PRIME. Write an algorithm PRIME2
which works exactly as PRIME, but in which the while-loop is modified such that
the variable :IT does not take the values of all numbers smaller than :NUM, but
only those that are smaller than or equal to :NUM .
The students are asked to verify the speedup by trying different inputs. Good candidate inputs to observe the increase in speed of course depend on the computer used.
Moreover, the students can try to make a simple running time analysis of PRIME2 themselves, which leads to the result that the loop is now executed at most (roughly) 1.41
times for inputs of length .
The above considerations give rise to another question, namely in which kind of analysis we are interested. To this end, the algorithm is modified such that the while-loop
is left as soon as a divisor of the input is found. The resulting algorithm obviously still
works correctly, but is it faster? Indeed, if the input is, say, an even number, the running
time of the new algorithm is a lot better. However, if the input is prime, both algorithms
take the same time. This is exactly the difference between a best case and a worst case
analysis of the algorithms running time.
Now we can follow the modular building of algorithms (see Section 2) and use PRIME2 as a building block to visualize the distribution of small prime numbers. More
precisely, the algorithm PRIMES shown in Listing 1.9 uses PRIME2 as a subprogram to

Examples of Algorithmic Thinking in Programming Education

121

Fig. 5. The distribution of prime numbers between 1 and 26. Instead of red and black
Fig. 2: The
distribution ofsquares,
primewenumbers
between 1 and 26. Instead of red and
use filled and unfilled ones.
black squares, we use lled and unlled ones.

Fig. 6. The distribution of prime numbers between 1 and 104.


Fig. 3: The
distribution of prime numbers between 1 and 104.
Listing 1.9: Visualizing primes.

However,
if the input
to PRIMES
:MAX is prime, both algorithms take the same time. This is exactly
the dierence
a best
case
pu lt between
90 fd 300
rt 90
pdand a worst case analysis of the algorithms
runningmake
time."TEST 1
Nowrepeat
we can :MAX
follow[the modular building of algorithms (see Section 2) and use
pu
rt
90 fd 10 lt 90 pd
PRIME2 as a building
block to visualize the distribution of small prime numbers.
PRIME2 :TEST
More precisely,
the
algorithm
make "TEST :TEST+1 PRIMES shown in Listing 1.9 uses PRIME2 as a
subprogram
to visualize the appearances of prime numbers among the rst :MAX
]
endnumbers.
natural
Listing 1.10: Visualizing primes more nicely.

Listing 1.9: Visualizing primes.


to PRIMES2 :MAX :ROW
to pu
PRIMES
MAX:ROW*10/2 rt 90 pd
lt 90 :fd
pu
lt "TEST
90 fd1 300 rt 90 pd
make
make
repeat" TEST
:MAX 1[
repeat
MAXfd[ 10 lt 90 pd
pu rt :90

PRIME2
:TEST
pu
rt 90
fd 10 lt 90 pd
make "REST
mod :TEST :ROW
PRIME2
: TEST
if :REST
= 0 :[TEST +1
make
" TEST
pu lt 90 fd :ROW*10 lt 90 fd 10 rt 180 pd
]
] [ ]
end
make "TEST :TEST+1
]

end
The result of executing PRIMES 26 is shown in Figure 5. Next, we can improve
the
appearance
by having
the squares
multiple
rows
(Listing
1.10). To
visualize
the appearances
of prime
numbersdrawn
amonginthe
first :MAX
natural
numbers.
this
end,
we
write
a
new
algorithm
PRIMES2
with
an
additional
parameter
:ROW.
The result of executing PRIMES 26 is shown in Fig. 5. Next, we can improve
the
The
turtle
moves
to
the
next
row
whenever
it
drew
a
number
of
squares
that
is
appearance by having the squares drawn in multiple rows (Listing 1.10). To this end, we
divisible by the value of :ROW. With PRIMES2 104 26 we obtain an output as
write a new algorithm PRIMES2 with an additional parameter :ROW. The turtle moves to
shown in Figure 6.
the next row whenever it drew a number of squares that is divisible by the value of :ROW.
An advanced exercise then deals with prime powers. The students should
With PRIMES2 104 26 we obtain an output as shown in Fig. 6.
solve this task at home, either alone or in small groups. The diculty of this
An advanced exercise then deals with prime powers. The students should solve this
exercise is due to the usage of a return statement, which is implemented by the
task
at home,
either alone
or in small groups. The difficulty of this exercise is due to the
output
instruction
in Logo.
usage of a return statement, which is implemented by the output instruction in Logo.
11

122

J. Hromkovi et al.

Exercise. A prime power is a natural number that has exactly one prime factor. For
instance, 27 is a prime power since it has the prime factorization
27 = 3 3 3 = 33.
Clearly, every prime number is thus also a prime power.
In this project, you design a program PRIMEPOW, which checks whether a given
number is a prime power. To this end, do the following steps:
1. Rewrite the program PRIME to obtain a program PRIMEOUT that uses the command output instead of drawing squares. If the value of :NUM is prime, the
value 1 should be returned, otherwise 0.
2. PRIMEPOW has one parameter :TEST. We want to check whether the value assigned to :TEST is a prime power (possibly with the exponent being 1).
3. First, the program checks using PRIMEOUT whether :TEST is a prime number. If so, Prime. is printed on the screen and the execution is ended using
stopall.
make "ISPRIME PRIMEOUT :TEST
if :ISPRIME=1 [pr [Prime.] stopall] []
4. Otherwise, all numbers smaller than the value of :TEST are iterated, and again
using PRIMEOUT it is checked whether the current number is a prime. If so, it is
checked whether it divides the value of :TEST without remainder.
5. If such a prime number is found, PRIMEPOW takes note of this by setting the
value of a variable :FOUND to 1. :FOUND is initialized with 0. If a second such
prime number is found, this will be noted since the value of :FOUND is already
1. In this case, More than one divisor. is printed on the screen and the execution is again ended with stopall.
6. Finally, if :FOUND is still 1 after all numbers were tested, Prime Power. Base:
and the prime number that divides the value of :TEST without remainder are
printed on the screen.
7. Check PRIMEPOW using small input values.
This introduction using Logo proved to be very valuable for the students in the succeeding lessons, where we implement more complex projects using Python. More precisely, they were able to learn important paradigms without having to worry too much
about syntactical details.

5. Conclusion
Programming education is a great opportunity to teach important core concepts of computer science on various levels and to establish algorithmic thinking as part of a broad
and general education. A necessary prerequisite is, of course, that we find ways to go
beyond teaching the specifics of a programming language and rather put emphasis on
those aspects of programming that lead to a deeper understanding of computer science.

Examples of Algorithmic Thinking in Programming Education

123

In this article, we have provided three examples of how programming education can
incorporate more general principles of algorithmic thinking. All three examples have
been taken from our well-tested teaching materials for primary school, high school, and
university level, respectively. Further details about our curricula are given in the complementing paper (Hromkovi etal., 2016).

References
Bell, T., Rosamond, F., Casey, N. (2012). Computer science unplugged and related projects in math and computer
science popularization. The Multivariate Algorithmic Revolution and Beyond, Springer-Verlag, 398456.
Bckenhauer, H.-J., Hromkovi, J., Komm, D. (2015). Programmieren mit LOGO Projekte.
http://abz.inf.ethz.ch/wp-content/uploads/unterrichtsmaterialien/primarschulen/
logo_projekte.pdf
Bckenhauer, H.-J., Hromkovi, J., Komm, D. (2015). Programmieren mit LOGO fr Fortgeschrittene.
http://abz.inf.ethz.ch/wp-content/uploads/unterrichtsmaterialien/primarschulen/
logo_heft_2_de.pdf
Freiermuth, K., Hromkovi, J., Keller, L., Steffen, B. (2010). Einfhrung in die Kryptologie. Springer.
Gallenbacher, J. (2008). Abenteuer Informatik. IT zum Anfassen von Routenplaner bis Online-Banking.
Springer, 2 edition.
Gebauer, H., Hromkovi, J., Keller, L., Kosrov, I., Serafini, G., Steffen, B. (2016). Programmieren mit
LOGO.
http://abz.inf.ethz.ch/wp-content/uploads/unterrichtsmaterialien/primarschulen/
logo_heft_de.pdf
Hromkovi, J. (2014). Einfhrung in die Programmierung mit LOGO Lehrbuch fr Unterricht und Selbststudium. Springer, 3 edition.
Hromkovi, J., Kohn, T., Komm, D., Serafini, G. (2016). Combining the Power of Python with the Simplicity of
Logo for a Sustainable Computer Science Education. Unpublished Manuscript.
Kohn, T. (2016). Python. Eine Einfhrung in die Computer-Programmierung.
http://jython.tobiaskohn.ch/PythonScript.pdf
Papert, S. (1993). Mindstorms. Basic Books, 2 edition.
Turing, A. M. (1936). On computable numbers, with an application to the Entscheidungsproblem. Proceedings
of the London Mathematical Society, 42(2), 230265.

124

J. Hromkovi et al.

J. Hromkovi is professor of informatics with a special added focus on computer science education at ETH Zurich. He is author of
about 15 books published in 6 languages (English, German, Russian,
Spanish, Japanese, and Slovak) and about 200 research articles. He
is member of Academia Europaea and the Slovak Academic Society.
T. Kohn is writing his PhD thesis in computer science at ETH Zurich.
The focus of his research is programming education, particularly in
high schools. He holds an MSc in mathematics from ETH and has been
teaching mathematics and computer science for 10 years.

D. Komm is lecturer at ETH Zurich and an external lecturer at University of Zurich. He studied computer science at RWTH Aachen
University and Queensland University of Technology. He received
his PhD from ETH Zurich in 2012. His research interests focus on
algorithmics and advice complexity.
G. Serafini is lecturer in the Computer Science Teaching Diploma
Program at ETH Zurich. He holds a MSc in computer science and
a teaching diploma in computer science from ETH Zurich. His research interests focus on the contribution of computational thinking to school education. He is a member of the board of the Swiss
Computer Science Teacher Association and a member of the Swiss
Olympiad in Informatics.

Olympiads in Informatics, 2016, Vol. 10, 125159


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.09

125

Programming in Slovak Primary Schools


Martina KABTOV1, Ivan KALA1,2, Monika TOMCSNYIOV1
Department of Informatics Education, Comenius University
Mlynska dolina, 842 48 Bratislava, Slovak Republic
2
UCL Knowledge Lab, Institute of Education
23-29 Emerald Street, WC1N 3QS London
e-mail: martina.kabatova@gmail.com, {kalas; tomcsanyiova}@fmph.uniba.sk
1

Abstract. In our paper, we want to present the conception of elementary programming in primary
Informatics education in Slovakia and the process of its integration into ordinary classrooms.
First, we will familiarize the reader with the tradition of so called Informatics education in
Slovakia and with the various stages of the process of its integration. We will formulate the learning objectives of the elementary informatics as a school subject in Slovakia (referring to Blaho
and Salanci, 2011) and give reasons why we believe that it offers an important opportunity for
developing informatics knowledge, computational thinking and problem solving skills. We will
primarily focus on the presentation of our arguments why we consider programming (in the form
rigorously respecting the age of the primary pupils) to be appropriate and productive constituent
of learning already for this age group. Several recent research findings, presented by Ackermann
(2012) and others support our position here. In the next chapter, we will present in detail the
conception of elementary programming and how it is implemented in the continuing professional
development (CPD) of primary teachers in Slovakia. We will examine which programming environments are being used, what kind of pedagogies and which specific learning objectives our
teachers apply. We will list programming concepts and identify corresponding cognitive operations, which we find appropriate for primary pupils. Then we will present and analyse the CPD of
our in-service teachers (and the position of programming in this process) which we have recently
implemented in Slovakia. Another important element of our CPD strategy is the well-known
Bebras contest (in Slovakia it is called iBobor or Informatics Beaver). In the next chapter of
our paper, we will apply qualitative educational inquiry methods to examine how our conception of elementary programming has really penetrated into primary classes in Slovakia. We are
also interested in how it is being received by the teachers and pupils. Through interviews with
the teachers we will identify different aspects of the whole process and main risk factors, which
may complicate or hinder the implementation. In the final chapter, we will study the tendency
to develop informatics and programming at the primary level in the context of various research
projects presented in the academic research literature. We will compare various key findings of
other research projects with our own experience.
Keywords: educational programming, primary education, computing, computational thinking.

126

M. Kabtov, I. Kala, M. Tomcsnyiov

1.Introduction
In recent years many educators, education policy makers and scientists call for integration of what they call computational thinking into primary education of all pupils. In influential documents like (The Royal Society, 2012) a need to distinguish computational
thinking (or computer science, informatics or computing education) from the ICT education is declared. However, reasons for such reflections differ computer scientists and
industry leaders feel that not enough young people (and only very few women) choose to
pursue a career in computer science and they believe that if pupils become familiar with
some informatics concepts (within their primary education already) they will favour it
later in their lives and careers. Others believe that computational thinking is equally
important and key skill as literacy and mathematical thinking and they call for a redefinition of literacy and for integrating digital literacy development into primary education
for the sake of educating a fully developed citizens to live in the digital world.
While ICT oriented education is included in most national curricula, many countries
do not pay any special attention to including other (and in our opinion more interesting
and more important) informatics concepts. However, we can observe important new step
in the UK by establishing computing as a compulsory subject in every school year since
September 2014.
The situation in Slovakia is different from most of the countries. Informatics as a
separate mandatory subject was established many years ago and for many years we have
been systematically preparing teachers for teaching it. The authors of our national curriculum took a great care to include topics from core informatics along with learning of
basic ICT skills.
Since Comenius University plays a key role in building National Informatics Curriculum (2011, 2015) we have a lot of experience with integrating educational informatics both into schools (primary, lower secondary and upper secondary) and into teachers
professional development (PD). Some activities with digital technology were recently
nation-wide integrated into early childhood education (or children 3 to 6) as well: see
e.g. (Pekarova, 2008) and (Kala, 2010).
The whole conception of informatics is a broad and interesting topic to study, but for
the purpose of this paper we fully focus only on one of its topics, namely, on programming at primary level in Slovakia. We will discuss its conception and the process of its
integration into ordinary classrooms. We will present and explain:
(a) The reasons and short history of implementing primary informatics as a modern
core subject taught in Slovak primary schools.
(b) Why we consider appropriate to have separate school subject focused on ICT and
informatics, while we also support integration of ICT across curriculum.
(c) What role primary programming plays in our conception of informatics education and what forms, methods and pedagogies we consider appropriate in this
context.
(d) How we proceed with the implementation of these objectives through in-service
teacher development.

Programming in Slovak Primary Schools

127

(e) What problems we have encountered, how this process actually evolves in our
schools, how the teachers read our objectives, which objectives and corresponding skills they have mastered, how they interpret them and finally which factors
of the implementation we and the teachers perceive as risky or unfulfilled.

Brief History of Informatics at Slovak Schools


First we will familiarize the reader with the tradition of informatics education in Slovakia and various stages of the process of its implementation. We will briefly describe how
the informatics education was established from the period of experimental education
at upper secondary schools in late 60s and early 70s, to the current stage of informatics
as mandatory school subject for students from grade 2 (i.e. 7 to 8 year olds) up to the
mid-upper secondary stage (i.e. 16 to 17 year olds).
In early 70s some of the vocational technical schools began to prepare students for
operating industrial machinery via computers. In these schools some students learned
basics of programming in Fortran and Cobol. Students first designed their programs using flowcharts, then they prepared corresponding punch cards which were then taken to
the computer lab. Students never saw the computer themselves since it was usually located in a different institution and it took up several rooms. In the late 70s some schools
built their own computer labs. In some industrial towns (where most of the vocational
technical schools were located) special central computer labs were established. At that
time new study programmes were launched at universities called informatics (at the
beginning called cybernetics).
In 80s most of the upper secondary schools opened special classes focused on informatics. However, appropriately qualified teachers were absent. In school year 1982/83
Faculty of Mathematics and Physics of Comenius University opened a new study programme focused on upper secondary informatics teachers pre-service education. Those
students had access to the university computer EC1010 where they could write and run
programs in Pascal. Soon after that several universities began to build computer labs
equipped with 8-bit computers (e.g., PMD-85, Didaktik Alfa, PP-01), often using a version of Basic as a programming language
Many activities designed to attract young people to informatics emerged in 1985
a P category of International Mathematical Olympiad started (later transformed into a
stand-alone International Olympiad in Informatics). A series of articles on programming in environments like Karel and Logo were issued in the Zenit magazine targeted
at secondary school students. Since 1986 a school subject Informatics and computers became part of the National Curriculum. Special classes focused on algorithms
and programming were established at several grammar schools and vocational technical schools.
In early 90s most of the upper secondary schools taught informatics. A special computer lab with several PCs was usually dedicated to this subject, mostly taught by specialized teachers. The educators inspired by success at upper secondary school developed
an experimental informatics curriculum also for lower secondary schools. For example,

128

M. Kabtov, I. Kala, M. Tomcsnyiov

Kosicka Str. Primary School in Bratislava opened a class focused on programming. Pupils aged 11 to 15 wrote game-like programs in a visual programming environment
called Comenius Logo (Blaho etal., 1995) and (Tomcsanyiova and Tomcsanyi, 1997).
In the second half of 90s computers become more affordable and many businesses and
households acquired them. In order to train students to use computers effectively, informatics in schools changed its orientation and became more user oriented students
learned how to create electronic documents (in T602, a text editor of that time), use
spreadsheet editor, send and receive e-mails, navigate files and operating systems etc. In
late 90s the National Curriculum was revised to incorporate five main topics Information around us; Communication through ICT; Problem solving and algorithmic thinking;
Principles of ICT; and Information society.
In 2008 a new National Curriculum for primary and secondary schools prescribed to
teach informatics as a mandatory core subject from year 2 (7 to 8 year olds) to mid-upper
secondary stage (16 to 17 year olds). At all school years five main topics of informatics
remain the same and they cover basic digital literacy, ICT user skills, programming and
core concepts of informatics, hardware and other digital technology related concepts,
digital safety and other information society related concepts. At different school years
the topics are taught differently first and foremost respecting the pupils, their age and
developmental stage.
There is an intense initiative in Slovakia to integrate digital technology into early
years (pre-primary) education as well. Through an EU funded project teachers in early
years education centres (kindergartens) are being educated to use digital technology appropriately with their children. Programmable toy Bee-Bot have been introduced, see
(Pekarova, 2008) and (Kala, 2010).
According to our anecdotal information, programming at upper secondary level is
mostly done in Delphi or Lazarus environments, with more and more schools gradually
switching to Python. At lower secondary schools, Imagine Logo and Scratch are popular
programming languages. At primary schools most widespread environments are Thomas
the Clown, EasyLogo and several other microworlds that have been created in our department (we will present them in chapter 3).

2. Elementary Informatics, Computational Thinking and Programming


In accordance with the recent report of Informatics Europe and ACM Europe (2013)
we will use the term informatics when we are speaking about the broad scientific field
behind the digital technology. For us informatics is also an umbrella term that includes
computing, ICT, and digital literacy basically all concepts that have anything to do
with digital technology, information or theory behind them.
An effort to distinguish various fields within school informatics is apparent in the
Royal Society report (2012). However, we use these terms in a slightly different way
from definitions provided there. By the term ICT we understand a set of user oriented
skills (e.g., using a text editor, spreadsheet editor, creating graphics, animation, working
with sounds ). Digital literacy in our context is understood as a set of basic skills that

Programming in Slovak Primary Schools

129

everyone should acquire during their education in order to use digital technology (not
only computers but all digital devices) effectively, safely and meaningfully to solve their
everyday problems and tasks.
To understand what exactly is covered by our informatics (as a school subject) lets
have a closer look at the five main topics in next chapter of our paper.

2.1.Informatics as a School Subject in Slovakia


Slovak National Curriculum (2011) codifies the following core school subjects rooted in
informatics science (however, since 2015 both subjects are unified as Informatika):
Informaticka vychova, or Elementary Informatics in English, for school years
2 to 4 (pupils aged 7 to 10), while whole primary education consists of year 1 to 4
(i.e. pupils aged 6 to 10).
Informatika, which translates as Informatics, for school years 5 to 11 (pupils
aged 10 to 17) at so called lower secondary and upper secondary schools.
For each of these subjects there is about 1 lesson per week, usually in a computer
lab. Besides these dedicated subjects many ICT (and some informatics) elements are
integrated across subjects as well, but that aspect will not be discussed in this paper.
Informatics as a core school subject is designed for every pupil regardless of their
gender, future career or highest level of education they will reach. Great emphasis is on
the age appropriateness the content and form should always respect developmental
stage of the pupils.
In all school years the five main topics of informatics remain the same, their content
is always designed to fit the specific age group. National curriculum of primary informatics is presented in detail in Blaho and Salanci (2011). At primary schools the five
topics cover:
Information around us is the most comprehensive topic that includes working
with text, graphics and multimedia. At primary school, pupils explore data structures simple tables, graphs, dictionaries and mind maps.
Communication via ICT pupils work with websites relevant to their interests;
they learn to use a web browser, e-mail client and chat.
Methods, problem solving and algorithmic thinking pupils learn to solve
various problems and write down solutions (using words, icons or specific commands), they learn to control an agent directly and later by planning commands
in advance. They learn to understand the causal connection between the program
and behaviour of the agent. In this paper we will focus solely on this part of school
informatics and specifically on the elementary programming.
Principles of ICT topic deals with hardware parts of the computer (keyboard,
mouse, display) and external devices. Pupils also learn to work with folders and
files.
Information society pupils learn about risks involved in using digital technology, about privacy and about the impact of information technology on the society.

130

M. Kabtov, I. Kala, M. Tomcsnyiov

We believe that these five topics cover the same concepts as three topics suggested in
the Royal Society report (2012): digital literacy, information technology and computer
science which resulted into introducing a new compulsory subject computing in the
UK since 2014.
In some other countries there is a strong initiative to include computational thinking and informatics concepts into all school subjects, see (Barr and Stephenson, 2011),
instead of creating a separate dedicated subject. However, Slovak tradition of informatics as a school subject is a long one (including corresponding pre-service and inservice teacher development) and we believe that informatics is a distinct and important
scientific field that should have a similar position in the education as mathematics or
physics. Another contributing fact is that it seems to be unreasonable to demand from all
the teachers to learn informatics concepts or how to incorporate computational thinking
into their respective subjects according to our experience they already struggle with
integrating basic ICT elements into their teaching.

2.2.Programming as a Component of School Informatics


The core topic in the National Curriculum (2011, 2015) of school informatics that is
most interconnected with informatics as a science is named Methods, problem solving,
and algorithmic thinking. In it we expect pupils to learn how to solve various types of
problems, externally represent a solution, and use such representation as an object to
think with about the problem. Carefully chosen problems and well thought out pedagogy can lead directly to computational thinking development and even rather deep into
elementary programming.
The term computational thinking was introduced and later developed by Wing,
who understands it as
a thought process involved in formulating problems and their solutions so that the solutions are represented in a form that can be effectively carried out by an information-processing agent (Wing, 2011).
Recently, an interesting study by Selby (2013) refines the definition of computational thinking as...
a focused approach to problem solving, incorporating thought process that utilizes abstraction, decomposition, algorithms, evaluation,
and generalization.
Wing and several other authors call for incorporating computational thinking into
formative education of children (Wing 2008), (Lu and Fletcher, 2009), (Lee etal., 2011)
and (Hu, 2011). In some countries the focus is still on implementing informatics education only into secondary school, see e.g. (Hubwieser, 2012) and (Settle etal., 2012).
Our main interest lies in developing computation thinking from the bottom i.e. form
preschool and primary education. However, it is difficult to choose appropriate form

Programming in Slovak Primary Schools

131

and content when it comes to this target group. According to Piagets theory of cognitive
development (1993), in accordance with Hu (2011) and also according to our own experience, most children reach the ability to work with abstractions only around their tenth
year and some of them even later. It is agreed in the relevant literature that abstraction is
the very essence of computational thinking. And yet we believe that supporting the development of computational thinking can productively start at the age of 5 or 6 by conducting well thought introductory steps leading to what we call elementary informatics.
Our first steps begin with direct manipulation with objects without the need to abstract or represent the process that is involved in their manipulation. While these activities may not resemble computational thinking at a first glance, we believe they are good
preparation for development of higher order cognitive skills.
By elementary programming we understand activities in which pupils perform
certain problem solving tasks of controlling an agent or planning its future behaviour
in a digital environment (programmable toy, microworld, programming environment...). We strongly believe that elementary programming is an excellent means for
developing, implementing and verifying problem solving skills within the domain of
computational thinking. If initiated at the primary stage of education, we also call it
primary programming. An interesting study on connection of computational thinking and programming can be found in (Selby, 2012). There are many age-appropriate
tools and environments that allow us to design meaningful and engaging elementary
programming activities while respecting childrens developmental stage. We believe
we comply with the Blackwells definition of programming (2002):
Programming involves loss of direct manipulation as a result of abstraction over time, entities or situations. Interaction with abstractions is mediated by some representational notation.
However, several problems arise if we want to define elementary programming activities. As we have already mentioned above children in our target group have not
yet developed their abstract thinking, and so abstracting over time itself is a problem.
On the other hand, we believe that many valuable activities can be conducted before
any kind of abstraction is involved. Moreover, these activities often have other features
that are compatible with programming (e.g., some sort of representation is being used;
planning future behaviour is expected etc.). We believe that learning to think computationally and to program ones solutions can be done gradually by doing specific
activities that only slowly lead to a true abstraction, decomposition of problems and
generalization of solutions.
We are aware that some authors consider programming at such an early age to be at
least disputable, see (Lu and Fletcher, 2009), some regard programming as a significant
form of computing but mathematical in its foundation, see (Hu, 2011). In this context
we perceive elementary (or primary) programming as a tool for developing early computational thinking skills. We believe that carefully chosen tools, activities and pedagogies are an excellent way of integrating both elementary programming and computation thinking into primary education of all pupils. We in accordance with Resnick
(2012) believe in Paperts dream of computational fluency for everyone, that

132

M. Kabtov, I. Kala, M. Tomcsnyiov

children should learn to program their own animations, games and


simulations and in the process learn important problem-solving
skills and project-design strategies and that it is necessary to expand the conception of digital fluency to include designing and creating, not just browsing and interacting.
However, we need to carefully build these skills gradually, always thinking about
age-appropriateness.
There are several educators that promote programming as a productive and engaging
activity even for very young children. They are looking for age-appropriate forms and
study how do children approach various programming situations.
Mogardo etal., (2006) deal with a pioneer experiment of Perlman who in 1970s designed a programming tool for preschool (and preliterate) children. The TORTIS system
consisted of physical floor turtle that was controlled by logo-like commands depicted on
plastic cards. Cards were placed into slots and after pushing a button they were executed
by the floor turtle. Both the agent and the commands were tangible. Authors themselves
admit that in the time of the described experiment there was only a little understanding
of developmental psychology of a child and Perlman probably had not designed the tool
in accordance with what we now would consider appropriate for such young children
(the paper describes working with 35 year olds). However, some of her observations
(analysed in 2006 by Mogardo etal.) are valuable even now e.g., that children didnt
manage to associate the screen commands with the movements of the turtle and even
after adding the plastic cards (which were basically physical representations of screen
commands for the turtle) children failed to understand that each card represents a movement of the turtle. We believe this problem is closely associated with a cognitive developmental stage of the children at the age of 5 they definitely do not possess the ability
to understand the connection between the plastic cards picturing commands and movements of the turtle on the floor. Our suggestion is to conduct different pre-programming
activities that do not involve external representations (e.g. playing with Bee-Bots or
even more trivial tools that involve one command, one move direct manipulations
of the agent at a time) and leave the programming activities involving abstractions
and representations to later stages when pupils begin to develop the understanding of
abstraction and external representations.
Ackermann deals with young children and their programming adventures in (2012)
where she describes three aspects of programming as observed by the work with preschool children:
1) making things do things (instruct them to follow and execute orders); 2) animating things (endow them with a mind of their own,
teach them to look after themselves); 3) poking things (modulate how
things act and interact by tweaking some parameters in their environment).
Ackermann admits that this is hardly a definition of programming per se and that
the concept of programming is difficult, ever-changing and bearing many meanings to
different people of different professions. However, she agrees that programming, at

Programming in Slovak Primary Schools

133

its core, is about giving instructions or commands to be executed by a machine.


She presents several settings where youngsters are asked to give and execute orders,
take over control. For example ambient programming is a new promising style that
has a potential to attract many children, even those who in general do not incline to
more traditional programming activities. Another take on ambient programming is described by Eisenberg (2009). On the other hand Ackermann refers to these activities
as programming (in a weak sense) and she puts the word programming into quotation marks. In agreement with this approach we also distinguish our activities from
hard programming and we will refer to them as elementary programming or primary
programming. Another approach to programming, currently getting growing attention
and becoming more widespread in all stages of education is physical computing and
educational robotics programming, see e.g. (Przybylla, Romeike, 2014) or (Mayerova,
Veselovska, 2016).
An interesting attempt at programming with primary school children is reported also
by Gibson (2003). Probably the most successful initiative for programming for children
is the Scratch community. Programming environment is being developed by researchers
at the M.I.T. and it is continuously being improved and thoroughly studied, see Maloney
etal. (2009) and Brennan etal. (2012).

3.Slovak Conception of Primary Programming


In this chapter we will present the conception of programming in Slovak primary education, based on current National Curriculum (2011, 2015) and materialised in the structure and content of the recent nation-wide professional development (PD) project for
700 primary teachers (see chapter 4). We will briefly characterise programming environments that have been used in the PD sessions and are currently being used in primary
schools, what kind of pedagogies teachers apply and what are their learning objectives.
We will analyse programming concepts and identify corresponding cognitive operations,
which we consider appropriate for primary pupils.
In the Slovak approach to primary programming we can identify three domains with
several sub-domains (with several overlaps and without any strictly predefined order
of implementation, although with numerous dependencies in developing programming
concepts and operations):
1) Solving problems and handling solutions.
2) Controlling an agent:
Direct control of an agent.
Indirect control (building and handling future behaviours).
Some advanced concepts of primary programming (e.g. parameters, loops and
procedures).
3) Tinkering with interactive environments:
Multiple agents and their properties.
Static scenarios.
Dynamic scenarios.

134

M. Kabtov, I. Kala, M. Tomcsnyiov

3.1.Solving Problems and Handling Solutions


One of the main learning goals of primary informatics is to learn how to solve problems,
and represent, evaluate, verify and reflect on their solutions. We consider concepts and
practices in this domain to be exceptionally productive and developmentally appropriate. They can naturally contribute to all topics of primary informatics including elementary programming.
In informatics education we focus especially on the procedure of problem solving
which leads from the initial to the final state (the solution) while keeping given rules.
Pupils probably do not perceive the procedure as the most important part of solving
problems, but from the perspective of informatics education it is the core of the problem
solving the product (drawing the house, cannibals and missionaries transported to the
opposite bank of the river, getting to the target square of the snake-and-ladder game)
is only a means of motivation. Therefore we choose problems that have interesting solving procedure (method or steps). We should always focus on the procedure of finding
the solution and on its externalized representation (see Fig. 1). We should not neglect
to verify if pupils are able to execute, communicate, analyse, evaluate and modify the
discovered method of solution.
When designing lesson plans dealing with problem solving, it is important to choose
both appropriate problems and learning activities to be conducted during the lesson. For
some problems there exist supporting digital environments that enable pupils to solve
them through direct interaction and visualization. This hands-on approach to solving
problems supports experiments, iterative solutions, repeating solutions and trying out
different solutions.
For example: the well-known puzzle about transporting the wolf, the goat and a cabbage across the river using one boat is an ideal problem for implementing via a software
environment (Fig. 2 left). By clicking objects pupils experiment with transporting them.

Fig 1. The first image is the required outcome a one stroke drawing. The second and the third images
(the third one being in fact a sequence of images) are possible notations of the procedure of
how to solve it. Both solutions demonstrate how a solving procedure can be noted.

Fig. 2. On the left the Wolf, Goat and Cabbage puzzle environment. Right: screenshot from a
similar puzzle with missionaries and cannibals, see http://game-game.sk/18394/.

Programming in Slovak Primary Schools

135

Usually they solve the puzzle by trial-and-error method. Though, when they are asked
how they have done it, they are motivated to reproduce and describe the solution and
some of them are easily prompted also to put down the sequence of steps for transporting
all items successfully.
If the environment is well designed it makes it easy to proceed from (1) solving the
problem, through (2) experimenting with the solution procedure to the (3) representing/recording the procedure for future repeated solving of the same problem (maybe
even without its immediate execution). These three steps in fact describe the advancement from solving problems to programming.
These are computational cognitive operations that are involved while solving problems and handling their solutions:
Discuss and think about the core of a problem, about the relevant information
provided by the problem assignment, about the conditions of solvability, about
an appropriate procedure that will find a solution, about the difficulty level of
the given problem, to look for similar problems that will help us to solve the
problem.
Use different strategies for finding the solution like drawing a diagram, listing all combinations, guess-and-confirm, divide problem into smaller parts, find a
similar problem, find a repeating pattern, look for the solution form the end etc.,
see Polya (1957).
Explain the solution to someone else, to teach a friend how to solve it (verbally,
by non-verbal means, using a specific language).
Learn from someone else how to solve the problem (using verbal or non-verbal
communication).
Write down the solution (by a picture, or series of pictures, using icons, text, video
or audio).
Reason about the language and the form of notation of the solution in order to
make it eligible for others.
Execute the solution and verify its validity, correct wrong steps of the solution.
Review certain properties of the solution (its eligibility, length, price ), assess
and compare it with several different solutions.
Look for different solutions of the same problem.
Reason about the non-existence of the solution.

3.1.1. Activities and Examples


An interactive microworld inspired by a task from the Bebras contest (see e.g. Dagien
and Stupurien, 2016) enables pupils to experiment with sorting a group of children according to their heights (Fig. 3). It is possible to switch two children by clicking on the
first one then the second one. This microworld also records the steps of the solution into
a text file. A teacher or a researcher can use it to find out what strategy pupils used if
they all solved the problem similarly or if they applied different strategies systematic
or more random.

136

M. Kabtov, I. Kala, M. Tomcsnyiov

Fig. 3. Interactive application for a problem solving task.

3.1.2. Pedagogy Observations and Recommendations


The specific organization of the lesson is up to the teacher she is responsible for choosing the problems and selecting the activities according to the learning goals of the topic.
Teacher can use many ready-to-use applications, microworlds and pre-made lesson plans.
Many problems can be solved without the computer. Many tasks from the Bebras contest
are suitable and they are available through the Bebras portal. The activities should be
built around a direct manipulation with physical objects; or if they are implemented via
some software application they should use appropriate pictures (dice, beads, building
blocks, animals, persons ). It is crucial to motivate the pupils to actively think about
the solution method and not to focus only on the end product i.e. they should realize
the difference between the procedure of drawing a house by one stroke and the resulting
drawing where they can see no longer how it was done.
3.2.Controlling an Agent
Second domain of primary programming deals with two important and crucial concepts
of pre-programming activities direct and non-direct control of an agent. The first one
is represented by a set of activities and suitable software applications that allow pupils
to command an agent (a toy, another child, an on-screen character or animal etc.) to do
something mostly, to move to a given location. Each command is immediately executed and a result can be observed. Non-direct control of an agent gets pupils into real
programming they are asked to construct a sequence of commands in advance, which
is then executed.

3.2.1. Direct Control of an Agent


Direct control of an agent can take place in a physical world where the teacher conducts
an activity during which pupils give other pupils certain pre-defined commands (e.g.
turn left, walk) to solve a given task (e.g. guide your friend from the desk to the door).
Sometimes the commanded child can be replaced by a toy that is moved by hand according to the commands. There are also toys that can be controlled by a remote control, or digital toys with control buttons placed directly on them. Ambient programming

Programming in Slovak Primary Schools

137

can also have similar characteristics, see (Eisenberg, 2009). In a software application a
pupil controls a virtual agent. It is crucial for such microworlds to maintain age-appropriateness using child-friendly graphics, presenting an engaging agent that a child can
identify with or that can be perceived as a hero protagonist. In both cases (physical and
virtual) the agent can execute only small set of well-defined basic commands make
a step, turn left, turn right, play a sound, take an object, pick a colour, set a pen size,
turn pen down etc. In many software applications the virtual agent can be controlled
directly but also by programming, i.e. without immediate execution of the command
(see the next chapter 3.2.2.).
The most basic task for an agent is to move from one place to another. This task is often motivating enough and pupils are willing to carry it out and think about the sequence
of commands to accomplish this goal. They gradually realise that:
Only a limited set of commands is available to use in the solution (in a physical
environment the teacher determines them, in a microworld they are usually set by
the application itself).
The current state of the agent is always represented by its visible attributes: rotation, position, pen colour etc.
The execution of each command has a very concrete, specific and unambiguous
effect on the agent and/or on the whole scene where it acts.
We choose the agents so that pupils are familiar with them and the activities they
perform are more or less grounded in their reality (e.g. a bee flies to the flower, an ant
moves objects) or at least actions of the agent should be believable (e.g. a turtle moves
around and draws a line with its tail). Most agents therefore are animals, vehicles or
human characters.
Many cognitive tasks listed in part 3.1. can be practised using activities mentioned
in this chapter by directly controlling the agent pupils can reason about the procedure
of finding the solution, they can explain their solution to a friend, they can review specific properties of a given solution and its correctness, or think about possible notation
of the solution.
Activities and examples
Each of the software applications that will be presented in this chapter has its own specific features. They use different agents and different control interface, some of them
record a sequence of commands. If the sequence of the steps can be recorded, we should
consider its level of abstraction the commands could be e.g. coloured pieces of paths
(Thomas the Clown) or arrows that guide the agent (World of the Ant, Bee Tasks). Another significant difference in various microworlds and applications is whether the agent
moves in a rectangular grid (Ice Cubes, Bee Tasks, World of the Ant, EasyLogo, Baltie),
in a graph (Thomas the Clown) or with no visible constraints (Scratch). Rotation mode is
closely related to the movement and the grid type the agent can rotate either relatively
or absolutely. Relative rotation means that the agent turns depends only on its previous heading; this is most common in open complex environments (Baltie, EasyLogo,
Scratch). Absolute rotation is common in simpler applications where the agent moves in
rectangular grid, usually only in four possible directions.

The agent in Thomas the Clown application is the clown on the bicycle. He moves in
the graph-like network of roads. The child controls him by clicking the blue, yellow
or red road piece in the right centre of the screen (see Fig. 4 left). The commands are
executed immediately but the sequence is also recorded at the bottom of the screen. The
task is to get Thomas from one place on the map to another.
In the Ice Cubes microworld the robot pushes the ice cubes (Fig. 4 right). It is controlled
by the keyboard keys and the task is to move all ice cubes to their designated places. The
sequence of moves is not recorded. Many similar microworlds are available on the web,
though they are often perceived as games without educational dimension. Both applications check if the solution is correct.
The World of the Ant application features an Ant as the agent (see Fig. 5 left). The goal
is to guide it through the maze to the door. Pink flower and blue star enable the Ant to
walk through colourful walls. The Ant is controlled by the keyboard keys. The sequence
is not recorded.
In the Bee Tasks the agent is a blue insect controlled by clicking the buttons with arrows
(see Fig. 5 right). The goal is to guide it to the flower. The sequence of the commands
is recorded on the bottom of the screen. Both microworlds verify whether the solution
is correct.

Fig. 4. On the left Thomas the Clown application, on the right an Ice Cubes microworld.

Fig. 5. On the left the World of the Ant application, on the right the Bee Tasks.

Programming in Slovak Primary Schools

139

EasyLogo is open environment in which it is possible to change the appearance of the


agent (in this case a frog). The agent is controlled by three buttons in the top right corner
(Fig. 6 left). Forward arrow moves it one step forward on the grid the agent moves
along the grid lines, not from centre of the square to the next square. The left and right
arrows turn the agent relatively to its current position. The goal is to guide the frog to the
pond. This application does not check whether the solution is correct, nor does it record
the sequence of commands in the direct mode.
Baltie is another open environment (Fig. 6 right). The grid where the agent (a sorcerer
named Baltie) moves is not visible. Similarly to EasyLogo there are three buttons for
the movement first turns the agent relatively to the left, second moves Baltie one step
forward and the third turns him relatively to the right. Baltie can conjure pictures a
child can choose pictures form the huge pre-prepared set. The picture will appear in front
of Baltie and it is also possible to construct more complex images consisting of many
smaller pictures. There is no in-built control of the correctness and the application does
not record the sequence of commands in this mode.
Some of these applications allow creating and adding custom tasks for pupils
World of the Ant and EasyLogo. In World of the Ant we cannot choose a different agent
or change the final goal of tasks, but we can design the maze and place object on different positions. EasyLogo is more opened it allows to change the agent to any picture,
set different backgrounds and completely rephrase the goal of the task (e.g. instead of
guiding a frog to the pond we can ask pupils to move the frog along a square shape). We
consider this an important feature the teacher can design her own tasks which are better suited for the pupils and their skills, or match the motivation for the specific lesson.
However, designing new tasks, creating custom pictures and related technical obstacles
put a lot of demands on the teacher.
Open programming environments, such as Baltie, Scratch or EasyLogo can be used
for the direct agent-controlling activities as well. However, a meaningful task has to be
designed (or programmed) by the teacher first. There is no in-built solution checking and
if the teacher needs such feature she has to virtually create the microworld to achieve
this. A pre-made and partially programmed activity e.g. in Scratch can simulate desired

Fig. 6. On the left is EasyLogo, on the right is Baltie.

140

M. Kabtov, I. Kala, M. Tomcsnyiov

features of direct agent control. A path for the agent is in the following example a part
of the backdrop (Fig. 7 right). The cat is controlled by keyboard arrows this behaviour
was programmed by the teacher in advance. Teacher also included a script that checks
whether the cat is at the end of the path or whether it deviated from the path earlier.
Similar assignments can be added to EasyLogo (Fig. 7 left), but it is not possible to add
automatic solution checking.
Pedagogy observations and recommendations
A teacher conducting these or similar activities must remember that the learning goal is
to build basic understanding of controlling an agent by specific commands. The pupils
should realize there is a causal connection between the commands and the behaviour
of the agent. Since the control is direct and each command is immediately carried out,
making this connection is possible for pupils before reaching formal operational stage
of their cognitive development. In each application we presented the behaviour of the
agent is visualized. This allows pupils to immediately see how they are progressing in
the solution. We recommend using activities or environments that automatically check
if the solution is correct. According to our experience, pupils are more motivated to
solve problems if they have immediate feedback on their success. In our approach we
always use direct control of an agent as an introductory activity to the very basics of
elementary programming.

3.2.2. Indirect Control of an Agent Building and Handling Future Behaviours


In the previous chapter we described activities in which the agent immediately carried
out each command. Next step may naturally be focusing on planning the whole sequence
of commands which will be executed only once it is complete. We call this approach
an indirect control of an agent. Here again we can control either a physical agent (a
classmate, a toy, or special programmable digital toy such as a Bee-Bot that is designed
for that purpose) or a virtual one living in a software application on the screen. When
working with physical agents pupils can write down the sequence of their commands on
the paper, or draw it using pictures (an interesting activity by itself is to design the proper
notation and discuss what proper means in this context). E.g. programmable Bee-Bot

Fig. 7. Similar assignments in EasyLogo and Scratch.

Programming in Slovak Primary Schools

141

does not display the sequence at all it is entered by pressing the buttons atop the toy,
but the child has to remember it or observe it when the toy moves according to the commands. When using software applications, notation is usually given by its designers
some applications use icons with arrows, icons combined with text or different kind of
pictures (e.g. colour of the road in Thomas the Clown).
Indirect agent control assignments usually have the same goal as activities described
in the previous part to guide the agent from one place to another. Again it is possible
to include also other actions e.g., picking and using items or avoiding obstacles. Since
the sequence of commands is explicitly recorded and thus visualized and editable
pupils can finish the sequence or add missing commands, or even correct the sequence,
i.e. work with the representation. We can classify the cognitive operations according to
what has to be done with the sequence of commands:
Construct the sequence that guides the agent from its initial position to a final required position according to the assignment.
Interpret a given sequence of commands (there are various ways of how to verify
the interpretation, the most straightforward is when pupils move the agent according to the given sequence e.g., by clicking on the grid squares).
Identify the final position of the agent after executing the commands.
Identify the correct sequence among several sequences (more advanced version is
to identify an incorrect sequence among several correct ones).
Complete the sequence if the last step is missing, or two last steps are missing, or
any step is missing.
Identify and correct an incorrect command within the sequence.
Find alternative solution, find a solution with specific properties (e.g. the path is
the shortest possible, or on its path the agent will cross equal count of yellow and
blue squares etc.).
Activities and examples
While most activities described above are suitable for implementation in a virtual microworld, it would probably be unreasonable to include all possible types of assignments
into one environment, thus getting too complex or too much time consuming for primary
pupils. Therefore several different applications are being used in our primary schools
that focus on specific tasks or certain groups of tasks.
Indirect controlling of an agent in Thomas the Clown is implemented e.g. in the strawberry picking task (Fig. 8 left): the robot is waiting at the entrance to the garden, once
a player completes a sequence of commands for moving and picking the strawberries,
the robot will execute it. The goal is to pick all ripe red strawberries in the garden. Sequence is created by clicking the icons in the left part of the screen and it is recorded on
the panel above the stage. When the sequence is being executed the active command is
always highlighted. This microworld automatically generates different gardens of 2 by
3 grid squares.
In the World of the Ant (Fig. 8 right) we can also choose indirect control mode. At the
bottom of the stage there is a set of commands four arrows are for absolute rotation

142

M. Kabtov, I. Kala, M. Tomcsnyiov

and icon with legs represents moving one step in to the direction set previously. The Ant
will carry out the sequence only after the child pushes the red button. The application is
open to design many different mazes.
The Bee Tasks microworld was designed to offer several possible types of tasks we
mentioned earlier. In its current version there are nine types the first one was already
described in part 3.2.1. as it is a direct control of the agent. The others are: interpreting
a sequence of commands, constructing a sequence (the Bee has to get to the square with
the flower, see Fig. 9 left), placing the flower on the square where the Bee will end up
after completing the given sequence (again interpreting the sequence), adding a missing
command (last one, last two, any in the middle), constructing a sequence (the Bee has
to end in the square with the flower, but there are obstacles as well), and identifying a
right sequence among several given (Fig. 9 right). A sequence is constructed by clicking on the icons with arrows based on the same principle as in Thomas the Clown
microworld.

Fig. 8. On the left Thomas the Clown, on the right World of the Ant.

Fig. 9. Two different assignments in the Bee Tasks microworld.

Programming in Slovak Primary Schools

143

EasyLogo offers a mode in which children plan and construct the sequence of commands (Fig. 10 left). However, this application behaves rather differently it executes
the commands immediately after they are dragged into the sequence it doesnt wait for
completing the sequence (commands are in the column at the right side of screen). In
this sense the agent is directly controlled. However, there is a button Run again which
re-executes the sequence after it is created.
If we want to use Scratch for this kind of activities, we first need to prepare a project
create a suitable backdrop, create sprite(s) and build the scripts for all functions, including script(s) to verify a solution (if we want to). An example below (Fig. 10 right) is an
activity in which the goal is to build a sequence of commands for the Beatle to move from
its green (start) square to another green (goal) square without even touching any other
non-white square. The backdrop is a grid of white and coloured squares. In the Beatles
scripts area there are four blocks prepared for the pupils already with their inputs properly set (move to the centre of a neighbouring square and turn left or right 90). Pupils will
construct the whole solution (script) for that situation by duplicating and snapping the
blocks into one script. This task has many variants of different levels of difficulty.
In both of these examples the task could be to fill in one or more missing commands
into the incomplete sequence (solution). Some of the environments presented so far offer an option for the pupils or for the teacher to add their own tasks of the same kind.
Scratch, World of the Ant and EasyLogo allow us to do so.
Similar tasks (where the goal is to guide the agent to a given goal) are used also in the
Bebras contest. Since 2010 primary pupils can be involved in the contest in a special
category specially designed for them. One task was inspired by Thomas the Clown (Fig.
11 left) the farmer has to get to his cow, but on his way he needs to grab the bucket.
All possible paths are depicted as a graph with edges of different colours. Pupils are
prompted to select the track which meets the criteria.
Second example from the Bebras contest is quite difficult task that proved to be
problematic as only 20 % of pupils solved it correctly, 17 % didnt answer at all. The
story is: A mouse is roaming in the maze, until it eventually reaches the cheese. Philip
was observing the mouse and used small cards with arrows to record its movements.
Unfortunately he dropped the cards and only two of them stayed at their places (see the

Fig. 10. EasyLogo and Scratch.

144

M. Kabtov, I. Kala, M. Tomcsnyiov

Fig. 11. Two Bebras tasks based on indirect control of an agent.

upper row of squares). Place the remaining cards and restore Philips record. The task
was interactive and pupils could drag the cards into empty slots using mouse.
The last described assignment illustrates that this kind of activity can be really difficult and can also be given to much older pupils. The variety of presented tasks show that
guiding the agent is very rich context with many possible activities and a lot of potential.
At the same time it is apparent that planning a sequence beforehand and executing it only
after its recorded is a programming-like activity that involves abstraction over time.
Also the specific notation and execution of the sequence by some automatic machinelike agent is a feature of full-flagged programming activity. However, these tasks are still
set in a concrete situations and their solutions do not require pupils to design universal
solutions that involve this kind of abstraction.
Pedagogy observations and recommendations
It proved to be crucial that the application itself verifies whether the solution is correct.
If the microworld offers several tasks or several levels of difficulty, pupils should not
be allowed to skip them freely. Most motivating environments have a game-like design
presenting a bit more difficult task in each level. The designers of the microworld should
always prepare a set of tasks to be solved by pupils. They should be ordered according
to their cognitive demands, they should be motivating and engaging, prompting pupils
to learn new concepts and challenging to engage more demanding (but still developmentally appropriate) cognitive operations. It is useful if the designer prepares several sets of
tasks as they can be used for achieving different learning objectives, in different classes,
for pupils at various stages of the learning process. Interesting option is to allow teachers
to create their own tasks, however this approach has proven to be far too optimistic as
only a small fraction of teachers are ready to do so.

3.2.3. Classification of the Microworlds Used for Direct and Indirect Control
of a Virtual Agent
In part 3.2 we have presented several applications, microworlds and environments that
are suitable for solving problems and learning computational thinking via programminglike activities. They are all suitable for primary school pupils as such or after certain
preparatory steps. We summarize their features in Table 1.

Programming in Slovak Primary Schools

145

Table 1
Features of microworlds
Movement
commands

keyboard keys
icons with arrows
icons with agent image
icons with colours
cards with text

World of the Ant, Ice Cubes


Bee Tasks, EasyLogo
Baltie
Thomas the Clown
Scratch

Agent rotation
style

without rotation
absolute rotation
relative rotation

Thomas the Clown


World of the Ant, Ice Cubes, Bee Tasks
EasyLogo, Baltie, Scratch

Grid type

graph
rectangles or squares

Thomas the Clown


Thomas the Clown, World of the Ant, Ice Cubes, Bee
Tasks, Baltie
EasyLogo
Scratch

rectangular lines
free movement (coordinates)
Notation (in direct without notation
control mode)
automatic notation

World of the Ant, Ice Cubes, EasyLogo, Baltie, Scratch


Thomas the Clown, Bee Tasks

Solution
verification

no verification
automatic verification

EasyLogo, Baltie, Scratch


Thomas the Clown, World of the Ant, Ice Cubes, Bee
Tasks

Agent actions

only movement and/or rotation

Thomas the Clown, World of the Ant, Bee Tasks,


EasyLogo, Baltie
Thomas the Clown, World of the Ant
World of the Ant, Ice Cubes
World of the Ant
Baltie, Scratch

collecting objects
moving objects
using objects
other
Goals

arrive at destination
other

Pre-made
activities

no in-built activities
set of fixed inbuilt activities
set of activities provided,
custom ones may be added

Thomas the Clown, World of the Ant, Ice Cubes, Bee


Tasks, EasyLogo
EasyLogo, Baltie, Scratch
Baltie, Scratch
Thomas the Clown, Ice Cubes, Bee Tasks
World of the Ant, EasyLogo

3.2.4. Some Advanced Concepts of Elementary Programming


In the previous two parts we focused on basic concepts that are in our opinion and according to our experience suitable and appropriate for all primary school pupils. Now
we will present several others more advance concepts which still could fit into upper
end of the primary programming, but probably not for the whole class and only with well
experienced teacher.
Parameters
In some applications parameters in existing commands are rather intuitive and easy to
use (e.g. in Scratch, Fig. 12 left). In this case there is no need to address this concept ex-

146

M. Kabtov, I. Kala, M. Tomcsnyiov

plicitly children will understand immediately how to use them. Rather intuitive way to
set the parameter is using a drop-down menu in Scratch there are several e.g. choosing a sound which will play by the play sound command. In this case pupils cannot
make a mistake. Another child-friendly parameter is pen colour chosen from the palette
(see EasyLogo displayed on Fig. 12 right). Parameters are present also in some modes
of World of the Ant and in Baltie environment.
Loops
Several of described microworlds provide loops Scratch, EasyLogo, Baltie. However,
they are usually present in more complex open programming environments. Led by our
department a small microworld focused on loop constructions was designed and developed (Fig. 13). In this application pupils control the Jumper who has to reach the door
by jumping over platforms. The microworld is designed as a game there are 24 levels
in which the child solves more and more complex situations (it is also possible to design
and add custom levels). Eventually the space for the commands becomes limited and
pupils cannot solve the problem without using a repeat loop. This design proved to be
highly motivating and pupils are deeply keen on completing the game. On the other
hand, one of the teachers using this microworld reported that only about a half of pupils
aged 8 to 9 years were able to learn to use the loop themselves. Loops appear also in the
LEGO WeDo programming language that is designed for primary schools. In this case,

Fig. 12. Parameters used in Scratch and EasyLogo.

Fig. 13. A game-like microworld named Jumper is focused solely on loop constructions.

Programming in Slovak Primary Schools

147

however, some commands implicitly contain repeated behaviour turning on the motor
means it will move until the program is stopped or some other action is assigned to it. As
our research team reported pupils use the loops block rather easily and they intuitively
understand their use in the programs they create for their robotic models.
Procedures
Some programming environments for primary pupils do not offer procedures (Scratch
1.4), others are designed to use them (EasyLogo, Scratch 2.0). According to our experience this concept is rather complex and is a good candidate to postpone to years 5 and
6. Here is an example of two procedures (Fig. 14 left) in EasyLogo. Pupils at first do not
design them, as these loops are already prepared in the activity; she is prompted to use
them in the program.

3.3.Tinkering with Interactive Environments


A programming environment named Living Pictures (influenced by Russian PervoLogo)
has been specifically designed in our department to teach pupils some object-oriented
concepts within elementary programming. In this environment pupils populate the virtual
world (represented by a background) with moving objects characters, animals, vehicles,
plants or anything they choose from a pre-made set of pictures or draw them themselves.
From the perspective of primary informatics pupils learn to control one or more objects,
define their behaviours, clone them, set their properties and reactions to events.
Each object is at first depicted as a Logo turtle the child should realise that this is
in fact an abstract object that can take any form. Each object has different properties, its
shape and position among them. Basic action of the object is its reaction to the onClick
event (e.g. it can move few steps forward). Other events are triggered when the project
is set to run and when objects collide, but we recommend to program these events later
with lower secondary school students, or with only some high achievers at the end
of year 4. This programming environment is open there are no pre-set activities. All

Fig. 14. EasyLogo procedures for drawing a yellow rectangle and red triangle are used to draw house.

148

M. Kabtov, I. Kala, M. Tomcsnyiov

assignments have to be designed and presented by the teacher. It is possible to add custom backgrounds and pictures. The teacher can adjust also the set of commands for the
objects so that the pupils see only a limited sub set (Fig. 15). We consider this high level
of customizability to be important especially if the application is designed for primary
pupils. Setting up the user environment so that it is as simple as possible is crucial for
the introductory lessons.
Another advantage of this application is that it is possible to export a project as an
executable file (EXE). Thus pupils can be motivated to create moving pictures for their
younger classmates (in accordance with Paperts principles of constructionist learning).
Pupils can present the executable file to their friends or relatives.
In next parts we will illustrate several activities that can be done in this environment. We will focus on shape, position and rotation of the object, and we will use three
events onClick, onRunProject and onCollision. We believe that the outlined sequence
of activities leads from designing a scene and setting the properties of objects to executing dynamic scenarios with multiple objects with different behaviour (which involves
abstraction over time and over situation as well, see Blackwell, 2002).

3.3.1. Multiple Agents and their Properties


In parts 3.1 and 3.2 pupils controlled only a single agent. Using Living Pictures (or
similar microworlds) it is possible to introduce multiple agents with different or identical properties. We prefer to tinker with properties that are visible shapes, positions,
and rotations. First, pupils should encounter objects with shapes that enable to see its
rotation (character, animal ) later they will learn that for some shapes rotations are not
observable (snowflake, sun). A good metaphor for describing such activity is a theatre
there are several actors on the stage, each of them has their own specific scenario and
eventually they interact. This description helps with distinguishing the preparation phase
(setting the properties, preparing sequences of commands) and the execution phase (the
objects carry out their instructions).
Activities and examples
A good introductory activity is populating the world pupils choose the background
(green hills and sky) and place several objects on it, then change shapes of these objects

Fig. 15. Whole set of all commands (left) and limited set designed for a specific activity (right).

Programming in Slovak Primary Schools

149

so they look like sun, clouds and trees. We can ask pupils to shrink or grow the objects
according to their positions in the background so that an illusion of depth is created (Fig.
16 left). The features used here are: adding objects, changing their shapes, scaling down
and scaling up and cloning objects. This activity can be done in many different settings
for example in the outer space (see Fig. 16 right). Rotation of the object can be also
used in static scenarios (the astronaut is looking towards the aliens).

3.3.2. Static Scenarios


Clicking on or touching objects in the screen is nowadays the most intuitive way of
interaction with the digital devices. This trend was set with the Windows interface and
now is reinforced with touch screen technology. Objects in Living Pictures have a preset onClick even that is triggered if the object is clicked by a computer mouse. Pupils are
already familiar with this event and assigning a reaction to the object when it is triggered
is the next step.
Activities and examples
In Living Pictures each object has its own event window into which the commands
for the object are dragged from the command palette. When designing static scenarios
pupils will change the shape, size and rotation of the objects. The most straight forward
activity is changing costumes. First the background is chosen, then objects are placed.
For each object that is a piece of costume the pupils will set a behaviour when it is
clicked its shape will change to the next one form the chosen set of shapes.
As an example let us select a winter background with a snowman. Objects that
will change their shapes with a mouse click are the hat, the broom, his face and buttons (Fig. 17 left). Similar projects are easily done in Scratch. The sprites have when
clicked event and a single next costume block rotates a set of prepared shapes for the
sprite. In our example (Fig. 17 right) three sprites can be clicked clowns hat, eyes
and mouth. Each object has the same and very simple script switch the costume to
the next one.
The greatest disadvantage of Living Pictures is that pupils can not immediately test
the script and see what happens (they have to close the event window first and then run
the project) in Scratch it is possible. In Living Pictures it is also not possible to see the

Fig. 16. Two static scenarios done in Living Pictures.

150

M. Kabtov, I. Kala, M. Tomcsnyiov

Fig. 17. Left: The t1 window displays the onClick event with one command change
shape to the next one which looks like a filmstrip. On the right similar project built in
Scratch.

set of shapes for the object or which one comes next. In both environments we should
encourage pupils to design the desired behaviour first for one object and only once it
is tested and it works properly they clone it. This is done in accordance with objectoriented approach in programming where the programmer first designs the prototype
object and its methods. Only after that is it reasonable to create inherited classes and
objects with modified behaviour. Primary school pupils can learn to distinguish different
objects with different properties and behaviour, or to tell what objects have in common.
We believe this level of abstraction is appropriate for the primary pupils in the highest
years (1011 year olds).

3.3.3. Dynamic Scenarios


Dynamic scenarios in Living Pictures environment involve assigning a motion to the
objects. Most common is setting an infinite loop for the motion, which is done by checking one of the options in the script (note that loop is not provided here as a programming
structure). Throughout these activities pupils better understand the difference between
preparation of the scene and running a project.
Activities and examples
In the Pond project pupils are prompted to set a background that will represent the pond.
They place an object and change its shape so it looks like a fish. Then they set its direction on our picture (Fig. 18 left) it will face right. In the event window they will command the fish to move forever forward. Default behaviour in Living Pictures is: if the
fish is on the right edge of the screen it does not stop to move but it reappears on the left
edge objects do not bounce by default. This is a deliberate design choice that enables
us to have an object which is forever moving to the right on a finite screen. After testing
the fishs behaviour pupils clone it. Now they can change direction for some of them, or
add some commands to onClick event (e.g. the fish disappears).
This is one possible set of activities in Living Pictures:
Setting properties (shape, position, scale, direction) and cloning objects.
One or more objects react to the onClick event.

Programming in Slovak Primary Schools

151

One object moves and reacts to the keyboard arrows; navigating this object is
similar to direct agent control activities described in 3.2.
Infinite movements of one or more objects; only one command is given to objects
(usually move forward) and it is set to repeat forever.
Infinite random movement of one or more objects on the scene, e.g. a butterfly is
flying on a meadow, or Thomas the Clown is cycling on the plaza.
Infinite (random) movement of one or more objects on the scene and their reaction
to onClick event. This activity is on the edge of game design pupils can prepare
a scene where objects move randomly, when they are clicked they disappear. Aim
of the game is to hit all the objects.
Infinite (random) movement of one or more objects on the scene and their reaction to onCollision event. These kinds of activities are probably too complex for
primary pupils, but if they are familiar with all previously listed concepts, they
may be able to do them. An example: one object is a basket that reacts to the arrow
keys, other objects in the scene are apples that are falling down (they move forever downwards), when the apple hits the basket it disappears. More complicated
scenarios can be devised, but we believe there is too much abstraction involved
and we do not consider this type of activity to be age-appropriate at Slovak primary level (consisting of only four years up to 10 years old pupils).

3.3.4. Pedagogy Observations and Recommendations


We believe that tinkering objects, their properties and behaviours is an excellent opportunity for the primary pupils to learn the very basics of the object-oriented approach to
programming. Activities in Scratch or Living Pictures are very intuitive. Pupils learn to
change and set properties of objects, to distinguish the development phase form the running phase, to plan the future behaviour of objects, incorporate looping actions of objects
and even begin to tinker with random values. It is crucial that these environments contain
a large set of pre-made graphics and they should be opened to adding custom pictures.
We believe that properly designed environment for tinkering with objects should:
Allow to add object easily.
Make changes in object properties (like shape, size or position) immediately visible.

Fig. 18. The Pond project created in Living Pictures.

152

M. Kabtov, I. Kala, M. Tomcsnyiov

Enable the object to react to at least three events: onClick, onRunProject, oOnCollision.
Feature easy pupils-friendly manipulation with objects and their properties by
clicking and dragging.
Enable cloning objects together with their behaviours.

3.4.Implementation of Elementary Programming: Various Ways and Various Tools


It is apparent from activities described in parts 3.1, 3.2 and 3.3 that core of primary
programming can be learned using specialized software applications or microworlds
that are (a) specifically designed for primary pupils and (b) designed to address the
learning goals we have listed earlier. There are many similar applications being created
around the world: Scratch (and its newer version Scratch 2.0), Scratch Jr., Microworlds
JR, LEGO WeDo or Baltie. Several powerful microworlds have been developed in our
department and made available for teachers and their pupils through various portals,
websites, projects and PD sessions. Those include Thomas The Clown, World of the Ant,
EasyLogo, Living Pictures, Jumper and Bee Tasks. Ice Cubes microworld and many
similar ones originate from Infovekacik an older Slovak on-line magazine for pupils
created in cooperation with our department.
Another productive means to support implementation of primary programming into
formal education for all children is the international contest Bebras. In Slovakia we
initiated a special category for primary pupils and many contest tasks are deliberately
designed to incorporate problem solving and elementary programming concepts. The
national success and high number of contestants suggest that pupils and teachers are
interested in this form of informatics.

4.Programming in Primary Teachers Professional Development


All Slovak primary teachers have to get a master degree from a pedagogical faculty of
one of our universities. They are not specialists they teach pupils of years 1 to 4 (6 to
10 years old children) all subjects (sometimes excluding foreign languages and/or informatics). In 2008 a new compulsory school subject was introduced primary informatics.
However, pedagogical faculties have failed to update their study programs to include
corresponding pre-service development for future teachers till today. Fortunately, a national project focused on professional development of in-service informatics teachers
was launched in 2008 (till 2011) and authors of this paper were involved together with
the teams from five universities across the country in developing its strategy and content and delivering it to 700 in-service teachers. The main goal of the project was to offer
a modern, up-to-date, high quality education necessary for teaching this new subject at
primary schools. Note that similar situation and PD strategy is being reported from the
Czech Republic by Vanicek (2013).

Programming in Slovak Primary Schools

153

Within the Slovak national project, 700 in-service primary teachers attended 18
study modules (each 6 hours long). Each module belonged to one of four tracks: Digital literacy; Informatics; Didactics of primary informatics; and Modern school. The
Informatics track included six modules: Computer and digital devices; Information
around us 13; and Problem solving and basics of programming 12. Teachers that
graduated from the PD should be able to use digital technologies both in their classes
and when preparing for them. They should perceive the elementary informatics as an
important part of pupils education and development, being able to meet the learning objectives of primary informatics as prescribed in the national curriculum. The
study materials and whole lecturing process was designed to prepare the teachers for
future development in digital technologies for new microworlds and new operating
systems, and also for new devices that would be used in the classrooms in near future.
Authors of the study materials and lecturers took great care to introduce the teachers
to a variety of software applications and appropriate teaching strategies. Teachers were
learning how to evaluate appropriateness of software applications and microworlds
and how to use them in the classroom.
From the perspective of this paper we find most relevant the modules dealing with
problem solving, elementary programming and corresponding didactical materials.
These areas had not been treated until then in any literature in our country (and hardly
anywhere) and designing that content and delivering it to 700 in-service teachers was
a real challenge and important innovative step towards new primary informatics. For
the sake of the project, several new microworlds had been created, e.g. EasyLogo and
Living Pictures, and participants used many other already existing microworlds and programming environments designed for primary pupils by experts in Slovakia.
One of the most successful new developments in the project was an idea and implementation of the Cards Tool (Tomcsanyi 2012). It is an authoring application that
enables the teacher to design simple but vastly variable activities for any (primary)
school subject. Participants of the project enthusiastically used the tool and created
interesting activities that confirmed that primary teachers are creative and persistent
and can use digital technology in their teaching. Since then, several thousand different activities created by the teachers themselves in the Cards Tool have been posted at
Slovak portal zborovna.sk.
Although we lost touch with most of the participants when the project finished, we
are interested in following how they manage to utilize new skills in their practice. Therefore we sporadically address a small sample of the participants and ask them to reflect
about the projects longer term benefits. From that (mostly anecdotal) data we may formulate several interesting observations about the implementation of the problem solving
and programming activities at primary level:
Primary informatics lessons are usually run in a special computer lab, dedicated to
primary key stage (older pupils usually use another computer lab).
In each year group (2, 3 and 4) around 5 to 8 lessons are allocated to problem solving and programming. These are usually taught in a row, often towards the end of
the school year.

154

M. Kabtov, I. Kala, M. Tomcsnyiov

Teachers are using the study materials extensively and share them with other colleagues. They have altered their lesson plans to incorporate teaching methods applied in the projects PD sessions.
Problem solving tasks (as presented earlier) are not highly popular among the
teachers; many teachers simply skip them. They rarely realise that those tasks are
not puzzles nor riddles, nor that their goal is not to find the solution by trial-anderror but systematically look for the solving method and reflect about the externally represented solution.
Teachers enthusiastically use some microworlds that were created for the project
most of all The Jumper, World of the Ant and The Living Pictures while EasyLogo
is less popular. Interestingly, each teacher has a strong preference for exactly one
of the microworlds.
Microworlds with the in-built sets of tasks of increasing difficulty and automatic
verification of the solutions are used the most. Teachers often say they cannot provide immediate feedback for all pupils in the group and primary pupils are very
keen on learning if they are progressing in the assignments. The sets should be
designed to be solvable within one lesson (45 minutes). It should not be possible
to skip the tasks in the set only after the task is solved correctly the child can
proceed to a harder one.
Open programming environments are difficult to use and the teacher has to be
better prepared for designing her own meaningful assignments and tasks within
such environments (often it requires to attend extensive specialized training for
the chosen environment). Our primary teachers probably have not reached that
level of expertise yet.
Most of the teachers are familiar with, visit and use the Infovekacik website an
on-line magazine for children with dozens of game-like microworlds. It would
be probably useful to create a web portal with similar content and add lesson
plans and recommended teaching methods. Teachers need good resources for their
teaching that would inspire them to search for new suitable microworlds and software applications.
Many teachers use The Cards Tool to design their own simple activities for
other school subjects (mostly language and science, only rarely for primary
informatics).
All teachers are appreciative and see high value of the projects PD and of the new
subject.
In conclusion, we believe that the national project and its PD programs were well
designed and conducted. The participating teachers do incorporate learned skills and
knowledge into their teaching. However, some of our plans proved to be too optimistic
most notably our inability to share with the primary teachers the importance and learning
potential of the problem solving tasks (as described earlier in 3.1). Another failed expectation was to assume they would design their own sets of tasks for the pupils to support
their informatics learning objectives. Teachers prefer to use the activities we prepared
for them and their PD. Clearly it is vital to provide suitable series of activities with each
microworld or digital toy/tool.

Programming in Slovak Primary Schools

155

5.Discussion and Conclusion


Presented approach to primary programming has resulted from our previous experiences
with teaching programming and developing programming interventions for all stages of
schools, including university study programs for future teachers of informatics, for several decades. Our professional roots lie in Logo culture, into which our Comenius group
has contributed by two internationally recognized versions of Logo: Comenius Logo and
Imagine Logo. From that background we inherited our endeavour to respect the needs of
students, together with other principles of Papert (1999) such as:
The Logo programming language is far from all there is to and in principle, we
could imagine using a different language, but programming itself is a key element
of this culture.
So is the assumption that children can program at very young ages.
And the assumption that children can program implies something much larger: in
this culture we believe (correction: we know) that children of all ages and from all
social backgrounds can do much more than they are believed capable of doing.
Just give them the tools and the opportunity.
Opportunity means more than just access to computers. It means an intellectual
culture in which individual projects are encouraged and contact with powerful
ideas is facilitated.
We have also learned how important it is to integrate programming into pupils learning experience only if they themselves see the meaning in doing so and perceive programming as a means to express themselves, to solve problems, to make things happen...
In the case of primary pupils, such programming should most probably restrict to building simple future behaviours in certain notational system and solving tasks, which arise
from handling such behaviours.
Although we consider elements of programming to be key constituent of informatics
in primary education, we do not develop it as a means to attract more students to later
Computer Science majors. We build it as a valued and legitimate core subject contributing to general education and complex development of every girl and every boy. Yet,
we hope, that it may consequently play that role as well the skills, knowledge, and
attitudes, which pupils gain in elementary informatics may later help them build sound
understanding of Computer Science principles.
Programming, which we consider appropriate for primary pupils, can be naturally
divided into three domains (while first domain should proceed the other two, we believe
that the second and the third ones can be implemented in any order or even in parallel).
They are:
Solving problems and handling solutions.
Controlling an agent.
Tinkering with interactive environments.
For each domain we have presented its main learning goals, corresponding computational concepts, computational practices, and essential cognitive operations to be
performed; selection of activities and examples, which in detail illustrate various types
of tasks and problems to be solved; several software applications that are being used;

156

M. Kabtov, I. Kala, M. Tomcsnyiov

and also several pedagogical observations and recommendations, which resulted from
our collaboration with the primary teachers.
Most of the programming environments, which are being used at Slovak primary
schools, are free applications, usually small microworlds focused on one of the domains
listed above, and one or several cognitive operations belonging to that domain. As partly
validated in chapter 4, teachers usually exploit environments which they find attractive
(although often not being able to verbalize which criteria they apply for judging this).
However, they clearly favour environments supplemented with teacher materials and
activities for pupils, and environments, which they may give away to their pupils for
their home work and play.
Our experience in implementing programming at the lower secondary stage ISCED2
(although not based on systematic evidence yet) shows that three domains presented
in the paper for primary stage can seamlessly be picked up and further elaborated in
lower secondary years to cover further cognitive operations (like conditional steps in
programs, abstractions, i.e. procedures without or with parameters etc.). However, extensive research to help us better understand cognitive demands of such programming
and real values of educational programming for the complex development of primary
and secondary students is inevitable. We have already undertaken some initial steps in
this direction, see e.g. (Gujberova and Kala, 2013).
As we document in chapter 1, informatics in upper secondary education has considerably long tradition in Slovakia. In recent years, it has been extended as a mandatory subject to lower secondary level (2005) and primary level (2008). In chapter 2, we
briefly characterized its curriculum and its learning goals and especially the key role of
programming within the subject.
We fully focused on educational primary programming in the paper. In chapter 3, we
presented in detail our approach to such programming together with corresponding computational concepts, cognitive operations, and programming environments employed in
our classes. In chapter 4, we then described how the CPD for primary in-service teachers
has been implemented with partial successes and numerous obstacles and challenges
that require permanent and intense support from the institutions responsible for education. In spite of many obstacles and slow progression, there are many positive and stimulating reactions from primary teachers who implement elementary informatics with
exceptionally positive involvement. They also report positive attitudes of their pupils.
The development of the subject of informatics in primary school is a long-term process. In it, we must thoroughly respect the requirements of the developmental appropriateness, carefully observe and analyse the needs of the pupils, respect all stages of their
learning processes, set correct priorities, and apply proper tools so that we support the
development of such programming, which our pupils will clearly benefit from. In this
aspect, we deeply agree with Papert, Ackermann and other seminal authors when they
advise not to learn programming for the sake of programming. Instead, we should...
use the knowledge of programming to create contexts where other
playful learning can happen. Children will engage in programming
if they can get something out of it right now not later when theyll
grow up, (Ackermann, 2012).

Programming in Slovak Primary Schools

157

References
Ackermann, K.E. (2012). Programming for the Natives: What is it? Whats in it for the Kids? In: Kynigos, Ch.,
Clayson, J., Yiannoutsou, N. (Eds.), Proceedings of Constructionism, Athens, Greece August 2012. National
& Kapodiststrian University of Athens, Athens, 110. Updated version obtained via CRN Japan:
http://www.childresearch.net/papers/pdf/digital_2012_03_ACKERMANN.pdf
Barr, V., Stephenson, Ch. (2011). Bringing computational thinking to K-12: What is involved and what is the role of
the computer science education community? ACM Inroads, 2(1), 4854. DOI: 10.1145/1929887.1929905
http://doi.acm.org/10.1145/1929887.1929905
Blackwell, A.F.( 2002). What is Programming? In: Kuljis, J., Baldwin, L., Scoble, R. (Eds.), Proceedings of
14th Workshop of the Psychology of Programming Interest Group. Brunel University, 204218.
Blaho, A., Kala, I., Tomcsanyiova, M. (1995). Experimental curriculum of informatics for 11 year old children.
In: WCCE95 Liberating the Learner: Proceedings of the sixth IFIP World Conference on Computers in
Education. Chapman & Hall, London, 829841.
Blaho, A., Salanci, L. (2011). Informatics in primary schools: visions, experiences, and long-term research prospects. In: Kala, I., Mittermeir, R. (Eds.), Informatics in Schools: Contributing to 21st Century Education.
LNCS 7013, Springer, 129142. ISBN 978-3-642-24721-7.
Brennan, K., Resnick, M. (2012). Using artefact-based interviews to study the development of computational
thinking in interactive media design. Paper presented at annual American Educational Research Association
meeting. Vancouver, BC, Canada.
Dagien, V., Stupurien G. (2016). Bebras a sustainable community building model for the concept based
learning of informatics and computational thinking. Informatics in Education, 15(1), 2544.
Eisenberg, M., Elumeze, N., MacFerrin, M., Buechley, L. (2009). Childrens programming, reconsidered: settings, stuff, and surfaces. In: Proceedings of the 8th International Conference on Interaction Design and
Children (IDC 09). ACM, New York, NY, USA, 18. DOI:10.1145/1551788.1551790
http://doi.acm.org/10.1145/1551788.1551790
Gibson, J.P. (2003). A noughts and crosses Java applet to teach programming to primary school children. In:
Proceedings of the 2nd International Conference on Principles and Practice of Programming in Java (PPPJ
03). Computer Science Press, Inc., New York, NY, USA, 8588.
Gujberova, M., Kala, I. (2013). Designing productive gradations of tasks in primary programming education.
In: Proceedings of the 8th Workshop in Primary and Secondary Computing Education WiPSCE 13. ACM,
New York, NY, USA, 108117. DOI: 10.1145/2532748.2532750
http://dl.acm.org/citation.cfm?id=2532750
Hu, Ch., (2011). Computational thinking: what it might mean and what we might do about it. In: Proceedings
of the 16th Annual Joint Conference on Innovation and Technology in Computer Science Education (ITiCSE 11). ACM, New York, NY, USA, 223227. DOI:10.1145/1999747.1999811
http://doi.acm.org/10.1145/1999747.1999811.
Hubwieser, P. (2012). Computer science education in secondary schools the introduction of a new compulsory
subject. ACM Transactions on Computing Education, 12(4), Article 16 (41 pages).
DOI:10.1145/2382564.2382568
http://doi.acm.org/10.1145/2382564.2382568
Informatics Europe and ACM Europe (2013). Informatics Education: Europe Cannot Afford to Miss the Boat.
Report of the joint Informatics Europe & ACM Europe Working Group on Informatics Education.
http://www.informatics-europe.org/images/documents/informatics-education-europereport.pdf.
Kala, I. (2010). Recognizing the Potential of ICT in Early Childhood Education: Analytical Survey. UNESCO
Institute for Information Technologies in Education, Moscow. ISBN 987-5-905175-03-9.
Lee, I., Martin, F., Denner, J., Coulter, B., Allan, W., Erickson, J., Malyn-Smith, J., Werner, L. (2011). Computational thinking for youth in practice. ACM Inroads,2(1), 3237. DOI:10.1145/1929887.1929902
http://doi.acm.org/10.1145/1929887.1929902.
Lu, J.J., Fletcher, G.H.L. (2009). Thinking about computational thinking. ACM SIGCSE Bulletin.
DOI:10.1145/1539024.1508959.
Maloney, J., Resnick, M., Rusk, N., Silverman, B., Eastmond, E. (2010). The scratch programming language
and environment. ACM Transactions on Computing Education, 10(4), Article 16 (15 pages).
DOI:10.1145/1868358.1868363
http://doi.acm.org/10.1145/1868358.1868363

158

M. Kabtov, I. Kala, M. Tomcsnyiov

Mayerova, K., Veselovska, M. (2016). How to teach with LEGO WeDo at primary school. In: Proceedings of
7th International Conference on Robotics in Education (RiE 2016), Vienna. To be published in the Springer
Series: Advances in Intelligent Systems and Computing.
Mogardo, L., Cruz, M., Kahn, K. (2006). Radia Perlman a pioneer of young children computer programming.
In: Current Developments in Technology-Assisted Education, 19031908. CiteSeerX: 10.1.1.99.8166.
http://citeseerx.ist.psu.edu/viewdoc /summary?doi=10.1.1.99.8166
National Curriculum, Informatics for ISCED 1 (2011, 2015). (In Slovak).
http://www.statpedu.sk/sites/default/files/dokumenty/inovovany-statny-vzdelavaci-program/informatika_pv_2014.pdf
Papert, S. (1999). What is Logo and who needs it. In: Logo Philosophy and Implementation. Highgate Springs,
Vermont: Logo Computer Systems Inc. ISBN 2-89371-494-3.
Pekarova, J. (2008). Using a programmable toy at preschool age: Why and How? In: Workshop Proceedings of
SIMPAR 2008, International Conference. 112121. ISBN 978-88-95872-01-8.
Piaget, J., Inhelder, B. (1993). La Psychologie de lenfant. Paris: Presses Universitares de France.
Polya, G. (2004). How to Solve It. Princeton University Press.
Przybylla, M., Romeike, R. (2014). Physical computing and its scope towards a constructionist computer science curriculum with physical computing. Informatics in Education, 13(2), 241254.
Resnick, M. (2012). Point of view: reviving paperts dream. Educational Technology, 52(4), 4264.
Selby, C.C. (2012). Promoting computational thinking with programming. In: Proceedings of the 7th Workshop
in Primary and Secondary Computing Education (WiPSCE 12). ACM, New York, NY, USA, 7477.
Selby, C.C. (2013). Computational thinking: the developing definition. In: ITiCSE Conference 2013, University
of Kent, Canterbury, England (e-prints), 6 p.
Settle, M., Franke, B., Hansen, R., Spaltro, F., Jurisson, C., Rennert-May, C., Wildeman, B. (2012). Infusing
computational thinking into the middle- and high-school curriculum. In: Proceedings of the 17th ACM Annual Conference on Innovation and Technology in Computer Science Education (ITiCSE 12). ACM, New
York, NY, USA, 2227.
Tomcsanyiova, M., Tomcsanyi, P. (1997). Experimental IT education for lower secondary school using Windows and Comenius LOGO. In: Learning and Exploring with LOGO: Proceedings 6th European LOGO
Conference. Budapest, 263272. ISBN 963-8431-91-1.
http://eurologo.web.elte.hu/lectures/tomcsa.htm
Tomcsanyi, P. (2012). Small interactive computer activities made by primary teachers. In: Information and
Communication Technology in Education 2012. Ostrava: University of Ostrava, 263272.
Vanicek, J. (2013). Introducing Topics from Informatics into Primary School Curricula: how do teachers take
it? In: Diethelm, I., Arndt, J., Dunnebier, M., Syrbe, J. (Eds.), Informatics in Schools: Local Proceedings of
the 6th International Conference ISSEP 2013, Oldenburg, Germany Selected Papers. Universittsverlag
Potsdam, 4151.
Wing, J.M. (2008). Computational thinking and thinking about computing. Philosophical Transactions of the
Royal Society A, 366, 37173725. DOI:10.1098/rsta.2008.0118
Wing, J.M. (2011). Research notebook: computational thinking what and why? In: The Link. Pittsburgh, PA:
Carnegie Mellon University.

Links to Microworlds and Programming Environments


Baltie: http://www.sgpsys.com/en/whatisbaltie.asp
Bee Tasks: see (Gujberova and Kala 2013), for the microworld itself contact the authors
Cards Tool: http://edi.fmph.uniba.sk/~tomcsanyi/Karticky/
EasyLogo: http://www.salanci.sk/EasyLogo/index.html
LEGO WeDo: http://www.legoeducation.us/eng/product/lego_education_wedo_software_
v1_2_and_activity_pack/2239
Microworlds JR: http://www.microworlds.com/solutions/mwjunior.html
Scratch: http://scratch.mit.edu/
Thomas the Clown: http://www.r-e-m.co.uk/logo/?Titleno=7485

Programming in Slovak Primary Schools

159

M. Kabtov, was an assistant professor of informatics education at


Faculty of Mathematics, Physics and Informatics at Comenius University, Bratislava. Her research interests included elementary programming, educational robotics and qualitative research methodology applied to educational research in informatics education. She is
a co-author of several research papers and learning materials dealing mostly with educational robotics. Since 2014 she runs an SME
distributing cochlear implants in Slovakia and provides services for
cochlear implants users. Currently she is planning to initiate a workshop providing a learning space for children with or without cochlear
implants where they could explore programming and building autonomous LEGO robots.
I. Kala is a professor of informatics education at Comenius University,
Bratislava. His professional interests include development of constructionist educational interfaces for learning for children and research in
the field of the impact of digital technologies on learning. Ivan is a coauthor of several programming environments for children, including
SuperLogo, Imagine Logo, Thomas the Clown and RNA (Revelation
Natural Arts) adopted by thousands of schools, home and abroad. He is
also an author or co-author of several books and textbooks on children
programming and informatics, which have been published in several
languages and countries in Europe and beyond. He has also been active
in several national and international policy efforts and initiatives. Ivan
represents Slovakia in the IFIP Technical Committee for Education.
From 2008 to 2013, he was a member of the International Advisory
Board of the Microsoft Partners in Learning initiative. From 2014 he
is a visiting professor at UCL Knowledge Lab, London.
M. Tomcsnyiov is an assistant professor of informatics education at
Comenius University, Bratislava. She is a guarantor of a bachelor study
programme for future teachers of informatics. She reads the courses on
programming and educational aspects of programming and conducts
corresponding research in the field of educational programming in all
levels of education. Monika is a co-author of several textbooks and
methodical teacher materials. She is also involved in designing small
educational software environments supporting informatics education
in Slovak primary and lower secondary schools. She develops tasks
and organizes informatics challenges for primary and secondary students, including Imagine Logo Cup, Scratch Cup and national Bebras.
Her area of research is didactics of programming for lower secondary
schools. She is a co-author of research papers in this area.

Olympiads in Informatics, 2016, Vol. 10, 161176


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.10

161

Collecting, Processing and Maintaining


IOI Statistics
Eduard KALINICENKO, Mrti OPMANIS1
Institute of Mathematics and Computer Science, University of Latvia
29 Raina Boulevard, Riga, LV-1459, Latvia
e-mail: eduardische@gmail.com, martins.opmanis@lumii.lv
1

Abstract. In this paper, we describe the whole process of creation, launching and maintaining
the IOI Statistics website project. Special attention is paid to the data acquisition and correctness
problems. Our experience may be useful for other International Science Olympiads still not having
their statistics portals.
Keywords. IOI, statistics, data collection, data maintaining.

1. Introduction
International Olympiad in Informatics (IOI, IOI-WEB) is the annual International Science Olympiad for high school students. Since the first IOI held in 1989, a certain
amount of data involving the competition is accumulated. However, due to a quite different quality of data for different years as well for different aspects of IOI, the data on
its own is not useful.
Usually, we need the data to answer specific questions, like the following ones:
Question 1.
Question 2.
Question 3.
Question 4.

What are the results of the competition for the given year?
In what years did the given country participate?
How many medals overall has a certain country achieved?
What results did the particular person achieve?

As far as International Science Olympiads are concerned, Question 1 is answerable


as publishing the results usually takes place. Sadly, however, publishing data about the
event often ends here. About further questions, to the best of our knowledge, before the
work on this project began, only International Olympiad in Mathematics (IMO, IMOWEB) had a centralized system that could answer all these Questions. Most of the other
efforts in collecting and maintaining the statistics were not made by the organizers. Most
notably, Waldemar Gorzkowski and dm Tichy-Rcs compiled the list of winners for
International Physics Olympiad (IPhO), but it was done in a separate PDF file, which is
not very customizable and exportable and included only medalists.

162

E. Kalinicenko, M. Opmanis

For International Olympiad in Informatics, the situation was even grimmer. Official
IOI website (IOI-WEB) only collected individual IOI results, and often only for the
medalists the issue we will cover more in-depth in Chapter 4. There also existed two
parallel projects the one by Tom Verhoeff (TUE-NL) and another one by Stanislaw
Waligorski (EDU-PL). Efforts to bring the results under similar format and process it
to display results per country (EDU-PL) were made, but both projects were out-of-date
and abandoned. Even the official website (IOI-WEB), despite several renovation attempts, often relied on official individual IOI websites, which have a tendency to go
offline in some cases.
The best resource at the time was SnarkNews project managed by Oleg Hristenko
(SnarkNews). However, despite being able to answer Questions 3 and 4 (on medalists
only), for old IOIs it only had a list of names and countries of all medalists in that year,
which was far from ideal. Furthermore, to the best of our knowledge, it did not appear to
solve the problems about data aggregation we will touch upon in Chapter 2.
With this in mind, the goal of the project was to collect as many data as possible and
aggregate them in a unified format. Further, the goal was extended to create and implement an IMO-like system to be able to explore the data collected. This paper tells the
story of this project from its inception to becoming part of the IOI infrastructure. We
hope that the lessons we learned could be useful to other International and Regional Science Olympiads looking how to overcome the same problems we tackled.

2. Data Collection
The work on this project began soon after IOI 2011. There was an interest in seeing the
cutoffs for past IOIs to observe how they have changed percentile over the years. It was
discovered that collecting the scores necessary for each kind of medal was not a trivial
task, but after some time the necessary data was gathered (IOI-EDU).
At this time, the scale of the problem IOI had with statistics was observed, as
some of the required data was only contained in one of the above-mentioned projects (EDU-PL), which in 2011 was already offline and was only available through the
Wayback Machine (Archive). Despite the initial goal to collect only cutoff scores, it
was quickly realized that in fact we have collected names, countries and at least total
scores of every single IOI medalist. This meant that at least for some sense (in this
case, IOI medalists) we can have some basic information, which led to the inception
of this project. However, to illustrate the incompleteness of the data available, we can
look at Fig.1 and see that currently only 61% of IOIs have full per-task scores of all
contestants available.
Again, limiting ourselves to IOI medalists only, it is trivial to process the raw data
in such a way which could help us easily answer Questions 2 and 3. The biggest challenge with aggregating data, perhaps surprisingly, lies in Question 4. It has a couple of
problems in its core and none of the resources available at the time appeared to have
tackled it. First, the mapping function from a person to a name is not injective. So we
cannot identify a person only by the name. Even more, as was discovered during the

Collecting, Processing and Maintaining IOI Statistics

163

Fig. 1. Availability of contestants scores for IOI 19892016.

collection of the data, even a tuple of name and a country is not enough to identify a
person there are two different people named Chen Zheng from China having participated in IOI.
Even bigger problem is the fact that the function mentioned above is not even a function. Putting aside the issue of a person changing a name (which in fact had occurred
before Jeppe Hallgren was known as Jeppe Petersen during IOI 2010), there is a serious issue of using a different spelling for the same person across different years. Most
notably, Gennady Korotkevich was sometimes spelled as Henadzi Karatkevich. This
whole issue is easily avoided with the help and understanding of the problem by the
organizers for example, the current IOI registration system asks leaders to pick specifically whether any delegation member is already in the registration database. However,
until this support was added, this crucial part of information was lost, and so the biggest
challenge in the whole data collection process was to recover this information.
In general, it was found that the same person is likely to represent the same country, although of course some exceptions are occurring like Fieke Dekkers (full name:
Sophia Antonia Janna Dekkers), who was a member of a delegation from both Netherlands and the United Kingdom or Rob Kolstad representing the USA and the United
Kingdom. Even limiting ourselves to contestants, which we are at this stage, Tomasz
Czajka has won two gold medals one for Poland and one for the United Kingdom.
Furthermore, it is reasonable to expect that if it is the same person, then he has competed in close to consecutive IOIs even if not strictly consecutive, a maximum gap
of two IOIs is expected. Again, this does not hold if we are considering all delegation
members, especially because it is common for former contestants to appear as a delegation member after some gap. However, at this stage, these two assumptions turned out
to be a good basis for determining whether two differently spelled or written names are
in fact the same person.
It was decided that it is not realistic to expect that decision can be made automatically without human input. However, it is certainly possible to provide a good set of

164

E. Kalinicenko, M. Opmanis

candidates for a human to look at in an attempt to minimize the human effort required.
For the spelling differences mentioned above (which usually were a lot smaller than in
the case of Gennady Korotkevich), Levenshtein distance (Levenshtein) between strings
was quite a good indicator if it were below a certain threshold, we would need to look
at the pair to determine whether they are in fact the same person. However, it did not
help to identify the second common case if a person has several middle names, then
often one set of middle names appeared in one year and a different one in another. In
an attempt to tackle this issue, Levenshtein distance algorithm was run between all possible subsets (with the size at least 2) of individual words from the original strings. If
any of those distances were small enough, the pair got triggered. In retrospective, while
this did not catch all the cases, we feel that it generated a good enough accuracy in the
original data set released.
Instead of unifying everything to a single format, as much data as we could find was
released as a single Excel file (IOI-EDU). This included some tricky bits which were not
documented well. For example, at IOI, the host can participate with the additional teams.
At present, these teams are not competing officially, and so their representatives simply
appear in the overall results at the proper position by the score but without any rank or
medal. However, nothing of a sort was mentioned in the regulations earlier on. This
led to a couple of precedents. Overall IOI 1989 winner, Teodor Tonchev, represented a
second Bulgarian team. However, the official IOI 1989 printed booklet ranks him and
declares a winner, so this interpretation was kept for that year. Secondly, in 1996 the
second Hungarian team won four bronze medals. They were ranked in all the data we
have seen and as per our inquiries, they appear to have received physical medals, so they
were kept ranked as well.
To conclude, in this Chapter, we have discussed the challenges encountered regarding collecting and processing the data. The most important issue we have identified here
is to avoid having a persons name and surname as the unique identifier. Even without a
centralized system organizers should make efforts to record and keep information that
can be used to tackle this problem in future.

3. Website Planning
At this point, there were no immediate plans to carry on. The data has been collected,
and it has even received sets of corrections, in particular by Ilham Kurnia and Mojca
Miklavec. However, creating a convenient interface to host the data collected was the
end goal while the created resource (IOI-EDU) was still much more useful than anything available was at the time, it felt that there would be a huge potential wasted if it
did not evolve further. To the best of our knowledge, while some efforts to create an
IMO-like website based on the data collected were stated to us, they did not transform
into anything concrete. That is the reason why in the spring of 2012 it was decided that
the matter should be put in our hands and as such the plans for devising the website
began to form.

Collecting, Processing and Maintaining IOI Statistics

165

The most crucial thing to get right was the database design. It is tempting to incorporate a lot of redundant information in the tables so that obtaining the data necessary is as
easy as possible. However, that could lead to huge problems with maintaining the tables.
As such, the effort was spent into carefully designing the database format to minimize
the amount of redundant data kept.
However, there are some notable exceptions to that in the database design. For
example, the rank and the medal contestant earned is kept in the competition record.
Technically this information is redundant since it can be obtained by analyzing others
results. Such decision was taken, firstly, to speed up the computation, as it eliminates
the need to query all that olympiads results if we are just interested in a single person;
and secondly, to ease the handling of unranked teams, as now we can explicitly set
a contestant to be unranked regardless of his position. The other example would be
keeping the score of a contestant in his records directly. This is not always a redundant
information since we do not always have full results (including the per-task scores).
However, even if we had, the could have been some additional problems at IOI 2000
to avoid zeroes at the end of the competition extra 50 points were awarded per day for
simply turning up, so in that case even if we had full results, the contestants total score
would not simply be the sum.
The next big decision is about the cooperation between the database and the web
server. It was thought that the database design was much less likely to change over time
than the web server, and as such it was decided to write complicated queries which take
care of everything, including composing and sorting the tables requested. This means
that it is incredibly simple to write a website, as shown in Fig. 2, which queries the data-

Fig. 2. Simple website to query the contestants results from the database.

166

E. Kalinicenko, M. Opmanis

base, once the queries are known. The website itself looks quite different nowadays, but
this table is remarkably similar to the one used today.
Initially, there was a third goal conceived, which was to unite all International Science Olympiads to be able to view a persons results across all competitions. Due to lack
of workforce, we decided to focus specifically on IOI instead. However, the database
was designed with more than one science olympiad in mind and as such the database
was split into two schemes the one with IOI-specific data, like competition records,
and the one with the common information (like information about people and countries).
As a result, it would be easy for some other olympiad to use the information from the
common information scheme, allowing people and countries to share information across
olympiads.
The website itself was coded in PHP, however as mentioned previously, most of it
is just the code for displaying the information in a pretty way on the website. The biggest part of the website devoted to this part is request processing, where we need to
combine all information obtained from forms to a single SQL query, resize photos, etc.
However, it would not take a ridiculous amount of effort to replace the web server with
another implementation of it. As for the actual design and structure of the website, it was
deliberately designed similarly to IMOs statistics. However, certain aspects were improved. For example, the country delegation page with photos is only easily accessible
while IMO has not finished yet, and we made sure that the accessibility of that page is
improved in the IOI statistics.
Finally, what is important to consider but easy to miss is the URL lifetime. Ideally,
you would like to make sure that the link created a long time ago would still work in the
future and would not become dead. This means that it is desirable to create a good set of
URLs at launch so that they are as human-friendly as possible. For example, compare
http://www.imo-official.org/country_individual_r.aspx?code=LVA and
http://stats.ioinformatics.org/results/LVA, where both of these links lead
to the same type of page. The major changes are also mostly backward compatible. For
example, the link which could have been made in 2012 (IOI-GDR) still works, despite
the server move and a country code change to comply with ISO standards. The only dead
links resulted after merging the entries of two persons (usually, after an e-mail that two
entries which we treat as different people are in fact the same person), and then using
the old link would not redirect to the new one, however this will get fixed it if we can
reconstruct with confidence which entries were merged from backups.
In retrospective, there were also a couple of bad design decisions. One of such is the
Login button. Its sole purpose is to allow the moderator to login into the system to
view and act upon submitted requests. However, it sometimes creates confusion when
users think that they are required to have an account to submit a change, while in fact
Edit or Add interfaces are available to anyone. Secondly, in the Edit interface,
there is a Submit button after every section (Basic Information, Contact Information,
Participation Information and Photographs). The reasoning behind this was a separation of requests by category with the idea that if additional verification is needed for
confirming an IOI role, we could accept the changes of contact information separately.
It turned out to be a bad decision, as on several occasions people had missed multiple

Collecting, Processing and Maintaining IOI Statistics

167

Submit buttons and were pressing the last one, which resulted in the loss of data when
users thought they submitted a change while only the photo was submitted. Finally, after
submitting a request, one receives a password to revoke it if needed. Sometimes people
seem to believe that this is the CAPTCHA-like process for the request and accidently
cancel them instead. Perhaps, revoking requests in a suggested way is not usual, and additional warnings are required to prevent misunderstanding.
To conclude, in this Chapter, we have discussed the challenges encountered while
designing a website. We feel that it is crucial to spend a considerable amount of time on
planning the back-end, which can be easily overlooked in favor of the front-end. We feel
that without a reasonable back-end, maintenance becomes unmanageable, which often
leads to project abandonment.

4. Acquiring Data
The biggest challenge was obtaining the perfect (correct and complete) data. We currently have data about 5775 people in the database. However, a lot of data is still missing. Beginning from the first Olympiad at 1989 hosts usually produced a full list of the
current IOI participants. Since 2000, this duty is stated in IOI Regulations (IOI-REG ver.
2014 S5.10(4)). Nowadays, publishing such a list is straightforward since all the data
is in the IOI Registration system and it is given to the host for organizational purposes.
However, now, we have no such official source of information for years 1990, 1993,
1995, 1998, 2002. Of course, now we can just point to the fact that these essential parts
of IOI history are not kept in an appropriate manner.
During the initial project (IOI-EDU), only information about contestants was collected. Now, we were suddenly interested in obtaining information on team leaders
and other delegation members. We limit ourselves just to international part of IOI
participants. In the IOI statistics, you cannot find information about representatives of
the host country (management, technicians, guides, volunteers, etc.) who help to organize the whole event. Also, from the historical perspective, IOI roles are changing. For
example, during the first IOIs team leaders comprised an International Jury not existing
anymore as a body. In 1993, there were such positions as President of the International Olympic Committee and President of the Technical Committee. According to
Regulations for that period, a president was nominated by the host country and today
seems to correspond to the role of Chairman rather to the position of the President of
IOI elected for a three-year term. Taking into account that it is almost impossible to
solve all these semantic clashes of the past, we defined the following twelve roles of
IOI participants: Contestant, Leader, Deputy Leader, Guest, Invited Guest, Observer,
President, Executive Director, Chairman, International Committee (IC) Member, International Scientific Committee (ISC) Member, and International Technical Committee
(ITC) Member.
However, even keeping names of roles as close to the current Regulations as possible, there appear unexpected problems. For example, according to the Regulations

168

E. Kalinicenko, M. Opmanis

current host country has one representative in the IC. But how to proceed if the host is
represented by different people in the in-between meeting of IC and at the IOI itself? Are
there two representatives of the host or one person (which one?) must be forgotten? Also,
in an attempt to avoid expanding the list of roles too much, by Invited Guests there are
marked different categories of people task authors invited by the Scientific Committee,
invited members of international organizations and associations and others.
We also provided functionality for the user to add some personal information to his
profile like Codeforces/TopCoder handles, homepage, e-mail and social network profiles. This was implemented partially due to the anticipation that the website might be
used for direct contacts and recruiting purposes by some parties and as such the ability
to add contact information was desirable.
While the situation for contestants was not perfect, but still reasonable, the situation
for other members of the delegations was close to appalling even national websites
listing all IOI teams for a specific country often omitted team leaders. However, it was
anticipated that national delegations at large still have access to that information, so the
natural choice would be to allow delegation leaders to provide and correct simply their
data in the system. However, that did not quite solve the problem of contact information,
and as well as that, it heavily relies on all delegation leaders being responsive to the
cause. So it was decided that the editing access would not be limited to a single person
for every country.
Instead, we decided to make the editing publicly available without any registration.
Compared to the denied approach, we realized that there would also be bad and malicious edits. However, our estimations said that this way we would receive more data;
and if we can filter the good requests from the bad ones, we would obtain more information this way, and since this was our primary goal, we decided to go with that. On
the downside, every change submitted to the system has to be approved by moderators, which created an additional effort on our side of things. In retrospect, there were
12818 non-spam requests (including rejected malicious ones) at the time of writing out
of 1295397 requests received overall, meaning that 99% of the requests we receive is
spam. However the vast majority of them never reach our eyes, so despite that, we feel
that it was the correct decision.
Furthermore, sometimes it benefited to go through a central point of moderation. For
example, some confusion was created with Sweden and IOI 1989. The national website
for Swedish Olympiads in Informatics lists IOI team for 1989 (SOI). Similarly, we have
received requests to add this team to the system. However, we were in possession of the
physical copy of the first IOI booklet having no records about a team from Sweden. After
some conversations with Pr Sderhjelm, former Swedish team leader, it was learned
that in 1989 there were two similar IOI-like initiatives. The Swedish team picked the
wrong one (we would be interested get more information about this event!), so they
did not participate in IOI 1989, and only joined IOI in 1990.
There were rare cases in the IOI history when teams mentioned in the official booklets did not participate in the competition due to visa issues or other, mostly political,
reasons. Such cases of disagreement with official documents were resolved using direct
communication with country representatives.

Collecting, Processing and Maintaining IOI Statistics

169

The biggest issue regarding missing data was generated by the rule that IOI had from
2000 for non-medalists their names and represented countries should not be published
(IOI-REG ver. 2014 S5.10(3)) in the results and as a consequence usually are lost from
freely available sources of information. We believe that not mentioning names of nonmedalists is contrary to Olympic spirit formulated by Pierre de Coubertin The most
important thing in the Olympic Games is not winning but taking part; the essential thing
in life is not conquering but fighting well (Coubertin). Contestants qualified to IOI as
a rule passed many national and regional events and are good even if they do not obtain
any medal at IOI. Furthermore, it creates a huge gap between the last bronze medal and
the first person without the medal. Despite these two people being right next to each
other in the standings, this rule made impossible for the second one to highlight his
achievement easily. But for this project, it was decided that we would not allow individuals to de-anonymize their results if they desire as this was deemed to be impossible
to verify. This concern turned out to be largely irrelevant, as we did not receive any such
requests.
In an attempt to at least not to lose these names for the history, in the IOI Regulations
since 2014 is stated that current IOI host is obliqued to Produce a full result list containing the final scores of all contestants, which is made available to the OED and ISC,
along with the data required to generate those scores; (IOI-REG ver. 2014 S5.10(4)).
On the public side of things, this rule began being pointless from IOI 2010, when the live
scoreboard during the contest was introduced. As such, other projects like SnarkNews
(SnarkNews) have full results available and so it became a pointless exercise to remove
the non-medalists names as the full results were already made available previously. In a
hilarious display, IOI 2010 website still hosts both versions of results anonymized and
de-anonymized. As such, we have taken a strict stance on maintaining the full results of
IOIs from 2010 onwards. Since then the risk of losing essential contest information is
diminished.
However, we fully respect this rule while no live scoreboard was available. Most notably, during the data collection stage, we have managed to discover the cached full results of IOI 2004, which presumably were published by organizers by mistake and were
taken down soon afterward. Including these data in the Excel file resulted in two e-mails
from IOI 2004 contestants asking to remove their name from the results. Their wishes
were respected, and this was also the main reason for the decision of not publishing the
de-anonymized results of IOI 2004s non-medalists at all on the present website.
The biggest issue with that rule, however, is the fact that it made it easy for IOI organizers to neglect the data. Since 2000 in IOI Regulations it was specified that three lists
should be published after the IOI:
1. The final scores of the medal winning contestants.
2. A list of all participants.
3. A list of all scores which contains no name/country information (IOI-REG, ver.
2014 S5.10(3)).
This rule does not oblique host to keep full scores for all contestants in any form.
Moreover, often only the first list (as the most important list of the whole event) was
published, meaning that non-medalists scores and all participants names were lost even-

170

E. Kalinicenko, M. Opmanis

tually. We believe this is the main reason why the data we have today is so incomplete,
which we believe was not anticipated at the time this rule was passed. Closing discussion
about the availability of full results, it should be added that also rare cases of disqualifications are not clearly marked in results. Usually, such contestants appear as the last
ones in the full results of the particular IOI together with contestants having no single
submission into grading system.
Despite the fact that IOI is an individual competition there are also some cumulative
statistics available regarding country participation in IOI: the total number of medals,
the total number of participated contestants, years of participation (counting only the
years when there were contestants on the team), etc. However, it is important to note
that we still keep records of all years even when there was only a single observer in a
delegation. Following the spirit of individual competition, countries are never explicitly
ranked; there are different ways to sort data, but you will never find rank next to the
name of a particular country.
To conclude, in this Chapter, we have discussed the challenges encountered while
attempting to collect additional data to obtain the complete picture and why this was
necessary in the first place. The takeaway message from this would be to make sure that
hosts publish all required information, and then make sure that the information is duplicated in some centralized location sometimes the last step would be forgotten, and the
information would be lost after the host website would go offline. While Web Archive
might save this information, it is not a good idea to rely on this.

5. Moderation
After reading the written above, a reader may have an impression that work is already
completed and new data may appear only after the current IOI, and there will be no updates in-between IOIs. Concerning IOI statistics, this is far from the reality. There is still
plenty of work to perform outside of IOI period. In this Chapter, we list several examples
of such work in the decreasing order of importance.
First, the main effort goes into the attempts to fill in gaps in the history by trying to
contact persons probably having missing documents. We are confident that it is impossible to get official data from hosts for five IOIs mentioned above. The most realistic
way is to contact former team leaders and try to fill gaps on delegation by delegation basis. The main obstacle here is that during early IOIs generations are changed
and without proper local archives it is almost impossible to restore information. As
well, different countries are differently interested in completing information regarding
their country. At the moment of writing paper statistics for 44 countries (from 101 or
43.56%) are completed.
Next, we have to deal with major requests concerning the website. These requests
usually affect the whole website, so they have to be dealt with carefully. To give an example, in the last season, two of such requests stood out.
For the first one, a former contestant argued that his name must be removed due to
right to be forgotten. We insist that IOI Statistics is the source of strictly statistical and

Collecting, Processing and Maintaining IOI Statistics

171

historical information, and we do our best to keep it correct and complete as possible.
Removing any essential piece of correct IOI information is against our efforts to complete the whole picture of the IOI history. Also described right to be forgotten cases
influenced just search engines (how easy is to find a particular piece of information) not
the availability of information itself.
For the second example, S. Maggiolo suggested adding gender information to contestants data on the official IOI statistics website (Maggiolo). Since we rely on authoritative sources of information and no gender information was kept until the creation of
the IOI Registration system, we do not believe its feasible to collect and verify the
gender of individuals. Furthermore, addressing contestants according to their gender
itself might be questionable we are not attaching other personal information like
race, religion, food preferences or disabilities; and we believe that some people might
object to releasing information on their gender as well. We understand that these statistics might be considered useful to answer some research questions, like whether
vegetarians tend to be better programmers, but we are not convinced at this point that
the official IOI website is the right place for that. This matter was recently raised with
International Committee.
Moving on, we have to deal with processing the usual requests. Commonly, these
are about changing/adding photos or updating contact information. If there is a request
to change contact information, requests are verified by checking a proposed link and
its relevance to the addressee. In unclear cases if contact information is known, before
approving, subject to the proposed changes or country representative is contacted. However, we periodically receive requests by e-mail (because these types of requests are not
supported by the system). Most commonly, the request is to merge two of the profiles
together because in reality it is the same person, which is usually quite easily verified.
Of course, not every request is legitimate and as such we have to struggle with hoaxes and improper requests. Relatively often, there are requests to change information in
an appropriate manner. For example, a request to add contestant of team X for the year
where we are confident that we have complete data (even more if suggested name is
like Anonymous). Or request to remove all contact information for some participant,
which appears to be fake after consultation with the addressed person. Or adding an improper photo like well-known Borat dressed in the green outfit (see Fig. 3). In general,
almost all such requests seem to be malicious than just joyful. Finally, there is also an
issue of dealing with spam. However, most of the work here is done automatically, and
just most sophisticated cases pass through the spam filter.
For readers, it may be interesting to know how the moderation of requests submitted
through the system looks from the inside. An example screenshot is shown in Fig. 3.
In the section Administration there is a possibility to clear spam, approve or reject
a batch of requests according to submitters IP address. Note that we can also change
the availability of the data for certain IOIs. This comes useful during the IOIs when the
results can be entered in the database long before they become official (and they will
not leak to the public), and we can then publish them with one click as soon as they
become official. Section Country Data offers a possibility to change color code for the
specified country in the main table of countries describing information completeness:

172

E. Kalinicenko, M. Opmanis

Fig. 3. Moderator interface screenshot (IP addresses are obfuscated).

green information complete, yellow information almost complete (usually completed


regarding contestants), red essential part of the information is missed.
All requests must be approved (button Grant), rejected (Reject or Spam) or
have the processing postponed (Hold). In the given example, both requests are real.
The first one would like to add a Twitter profile to persons requisites and, therefore, will
be approved. The second one is obviously non-legitimate so that it would be rejected. It
is worth noting that even if the photograph were of the person in question, it would still
get rejected as we aim to have more passport-like photographs on the website (although
this desire is not expressed clearly), where the head occupies a significant percentage of
photos vertical space.
To conclude, in this Chapter, we have discussed the challenges encountered while
maintaining the website. We feel that the most important issue is not to take accepting any edit requests lightly. While it is understandable that occasionally some false
information provided by the community might slip through, if this information is false,
one would lose the reputation which is crucial if you want to be a source of credible
information.

6. Launch and Steps to Becoming Official


The statistics website was launched during IOI 2012 after a presentation during the
IOI Conference. The results of IOI 2012 itself were added about a week after it was
finished. The website accumulated an average of 140 unique daily IP visits during first
two months after launch. The appeal to obtain more information was also fruitful. In the
period until the next IOI we have granted 1233 requests, whether they were submitted

Collecting, Processing and Maintaining IOI Statistics

173

by the community entirely, or we have committed them ourselves based on the raw data
submitted by the community.
Meanwhile, in the same period, we have received access to the official IOI website
(IOI), which at the time was quite outdated. This meant that we could start to plan on
how to move this project under the official domain. Initially, the idea was to incorporate
essential information about IOI on the project and replace the original IOI website completely. However, this was later abandoned for cleaning up and maintaining the original
website and hosting the statistics portal as a separate subdomain.
During IOI 2013, it was voted by the General Assembly (GA) to sponsor maintenance of the original IOI website and the development of this project from the IOI
budget (IOI-2013-GA-MIN). This allowed us to fulfill the goal mentioned above and in
April 2014 the website was moved to the place where it currently resides (IOI-STATS).
While we were still supplementary to the official results published by the organizers, for
IOI 2015 (IOI-2015) they did not do so and instead simply linked to our project, which
we consider being a final step in becoming official.
One of the other aspects of becoming official outside of recognition is the ability to
access parts of official data. This is best showcased by the process of releasing the list of
participants before the IOI occurred. Usually, every year well in advance of IOI there appears a popular thread on Codeforces and TopCoder, where the community would share
its knowledge on the upcoming IOI contestants, and that would be summarized, creating
an unofficial IOI contestant list. The ability to display participant list was first added to
the website for IOI 2013. At that stage, we did not have any access to the official data in
the registration system (IOI-RS) and as such, we simply mirrored the thread on Codeforces for that year. After the organizers had released the official list, the websites data
was modified to reflect that.
For IOI 2014, we decided to keep it official and did not take any data from the community, as some talks on accessing official data began already. Unfortunately, it did
not reach the conclusion in time, and as such we have waited until the official data was
released. Strangely enough, initially it got released exclusively on the mobile app for
Android. Still, it was mirrored to the database and for some time, it was the only convenient way to view contestant list if you do not have an Android device. Subsequently, we
received the necessary data (name, surname, role, and country note that we always receive information on per-need basis and do not receive unrelated and personal information to the cause, like passport details, for obvious reasons, including the one of privacy)
from the official IOI registration system, so we could add some additional delegation
members (like guests, who were not displayed in an app). Also, we discovered a discrepancy between the registration data and the data published by the organizers, which was
then addressed and fixed.
In the meantime, this issue was discussed within IC to ensure that we could receive
the data from the IOI registration system sooner. Additionally, the check mark was added
to the system to allow us to publish the participants photographs as well. Because of
these, for IOI 2015 we were able to publish the participant list soon after the registration
deadline was over and we were the first resource to do so. We were able to publish 228
photos, where we were given permission to do so. Extra effort was made to avoid ac-

cidental leaks of personal information, where some people uploaded a full passport copy
instead of a photo. Even despite the fact the we shrink the photographs to 180 pixels in
height, and it would be very unlikely that there would have been any leaks because of
that, we still manually cropped those photographs.
Finally, the process of becoming official means that you receive a lot more credibility over time and as a result people start relying on and linking to your information.
At the moment of writing this paper, there are over 9000 links to stats.ioinformatics.
org according to Google search. Some of them are not only simply linking to results or
individual statistics, but also refer to actual statistics. For example, the post on Quora
(Quora) was attempting to answer the question of the hardest IOI problem based on the
average score per contestant available on the website. Of course, not all of the links are
of the same level of importance. Moreover, there are incorrect ones. For example, link
in the article (UG-RU, 2016) claims that there will be problems from the corresponding
IOI where there is currently just statistical information about tasks.
Investigating pages with links, we found one, which may be the example why we
cannot take any responsibility for the way how provided statistical information is used.
For example, in the forum post (Apricity) photos from the IOI Statistics regarding Chilean contestants are extracted and an attempt to evaluate demographics based on ethnicity
was made, which is not something that we approve or imagined that would happen based
on the data we released.
To conclude, in this Chapter, we have discussed the process the website took to obtain an official status. Furthermore, some benefits of the official status were provided.

7. Future Work
One of the evergreen tasks is encouraging people to fill in missing parts of information. Just as a reminder for potential submitters information can be submitted in a
few simple steps. First, consult the People page of the particular country to find the
particular person whose information you would like to update. If such a person already
exists there, follow the link under that persons name and push Edit in the top-right
corner of the page. After adding/changing appropriate information, click the Submit
right after changed section. Be aware there are four sections having separate Submit buttons, so if you want to edit information in multiple sections, you would need
to submit multiple requests to the system! Only if you cannot find the person in the list
of already known people, push Add and provide all known information about the
particular person. In this case, Submit must be pushed just once at the very end. As a
backup scenario, there is always a possibility to send all relevant information to us we
will add it by ourselves. The main principle do not keep valuable information about
former IOIs a secret!
As far as the further development of the website is concerned, the current plan is to
refactor the web server code completely. When it was created, not many efforts were
put into making it maintainable and as the result the code became quite unreadable over
time, and it is now quite challenging to add new features without accidentally break-

Collecting, Processing and Maintaining IOI Statistics

175

ing something. After that, it would become feasible to considering open-sourcing this
project so that other olympiads, like Regional ones, could use this platform to host their
results. As well as that, perhaps some additional functionality could be contributed by
the community then, as is currently happening with CMS (CMS), which is the competition system currently used at IOI.

8. Conclusions
In this paper, we have touched upon various aspects and challenges we have encountered
in creating and maintaining a centralized place for collecting official IOI data. While it
is not a small project and some International and Regional Science Olympiads might not
have the resources to tackle this at the moment, we feel that it is still important to consider our experience. While the project itself is hard work, many challenges that made it
hard are solvable easily if they would have been considered at the time. So we hope that
after reading our experience some Olympiads might pay a bigger attention to the issues
discussed here and make it a lot easier to execute the project of this scale.

Acknowledgements
We would like to thank Oleg Oshmyan for all the technical help received during the
creation of this project and maintenance of the servers. We also extend our gratitude to
Sergey Melnik and Vyacheslavs Kashcheyevs for supporting this project and giving us
fresh ideas. We would also like to thank Ilham Kurnia and Mojca Miklavec for providing
a massive amount of data in the early stages of this project. Finally, we thank IOI community for providing the financial support for this project.

References
Apricity. The Apricity. Why do people still think that Chile doesnt have a mestizo majority?
http://www.theapricity.com/forum/showthread.php?184231-Why-do-people-stillthink-that-Chile-doesn-t-have-a-mestizo-majority
Archive. Internet Archive: Wayback Machine. https://archive.org/web/
CMS. Contest Management System. https://cms-dev.github.io/
Coubertin, P. Quotes. http://www.brainyquote.com/quotes/authors/p/pierre_de_coubertin.html
EDU-PL. Results of International Olympiads in Informatics, formerly at:
http://www.oi.edu.pl/ioires/
Levenshtein, V. I. (1965). Binary codes capable of correcting deletions, insertions, and reversals. Doklady Akademii Nauk SSSR, 163(4), 845848.
IMO-WEB. International Mathematics Olympiad. http://www.imo-official.org/
IOI-2013-GA-MIN. Minutes of the General Assembly of the 25th International Olympiad in Informatics.
http://ioinformatics.org/a_d_m/ga/ioi13/GA-minutes-jul2013.pdf
IOI-2015. The 27th International Olympiad in Informatics. http://ioi2015.kz/
IOI-EDU. International Olympiad in Informatics: The Results. http://www.eduardische.com/ioi/main

176

E. Kalinicenko, M. Opmanis

IOI-GDR. Information regarding the former German Democratic Republic in the statistics of the International
Olympiad in Informatics. http://ioi.eduardische.com/countries/GDR
IOI-REG. Official Regulations of the International Olympiad in Informatics.
http://ioinformatics.org/rules/index.shtml
IOI-RS. Registration System of the International Olympiad in Informatics.
https://ioiregistration.org/
IOI-STATS. Statistics of the International Olympiad in Informatics.
http://stats.ioinformatics.org
IOI-WEB. International Olympiad in Informatics. http://ioinformatics.org/
IPhO. International Physics Olympiad statistics. http://ipho.org/statictics.pdf
Maggiolo S. (2015). An Update on the Female Presence at the IOI. Olympiads in Informatics, 9, 127137.
http://ioinformatics.org/oi/pdf/v9_2015_127_137.pdf
Quora. Thread Specific Problems in International Olympiad in Informatics
https://www.quora.com/What-are-the-hardest-problems-from-past-IOIs
SnarkNews. SnarkNews on IOI. http://ioi.snarknews.info/
SOI. Swedish Olympiads in Informatics. http://www.progolymp.se/1989
TUE-NL. Former website of the International Olympiad in Informatics.
http://olympiads.win.tue.nl/ioi/
UG-RU (2016). Information about the 28th International Olympiad in Informatics. Uchitelskaya Gazeta, Number 4. (In Russian. ). http://www.ug.ru/archive/63529

E. Kalinicenko is in his final year of studies at the University of Cambridge towards BA/MEng in Computer Science. He obtained four medals at IOIs, including a gold medal at the IOI 2011 and had obtained
an honorable mention at IMO 2010. Participated in two ACM International Collegiate Programming Competition World Finals one as
a contestant from University of Latvia and one as an on-site coach of
University of Cambridge team. He is a member of the Latvian jury for
high school programming competitions and has been a deputy leader
of Latvian delegation at IOI 2013.
M. Opmanis is a researcher at the Institute of Mathematics and
Computer Science of the University of Latvia. He is one of the main
organizers of Latvian Olympiad in Informatics, was deputy or team
leader of Latvian IOI and Baltic OI teams. M.Opmanis was head of
jury of Baltic Olympiad in Informatics at BOI 1996, 1999, 2004 and
2012. From 2012 till 2015 he was a member of IOI International
Committee.

Olympiads in Informatics, 2016, Vol. 10, 177194


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.11

177

Distributed Tasks: Introducing Distributed


Computing to Programming Competitions
Adam KARCZMARZ1, Jakub CKI2, Adam POLAK3
Jakub RADOSZEWSKI1,4, Jakub O. WOJTASZCZYK5
Faculty of Mathematics, Informatics and Mechanics, University of Warsaw
ul. Banacha 2, 02-097 Warsaw, Poland
2
Department of Computer, Control, and Management Engineering Antonio
Ruberti at Sapienza University of Rome
via Ariosto 25, 00185 Roma, Italy
3
Department of Theoretical Computer Science, Faculty of Mathematics and
Computer Science, Jagiellonian University
ul. ojasiewicza 6, 30-348 Krakw, Poland
4
Kings College London
Strand, London WC2R 2LS
5
Google Warsaw
Emilii Plater 53, 00-113 Warsaw, Poland
e-mail: a.karczmarz@mimuw.edu.pl, j.lacki@mimuw.edu.pl, polak@tcs.uj.edu.pl,
jrad@mimuw.edu.pl, onufry@google.com
1

Abstract. In this paper we present distributed tasks, a new task type that can be used at programming competitions. In such tasks, a contestant is supposed to write a program which is then
simultaneously executed on multiple computing nodes (machines). The instances of the program
may communicate and use the joint computing power to solve the task presented to the contestant. We show a framework for running a contest with distributed tasks, that we believe to be accessible to contestants with no previous experience in distributed computing. Moreover, we give
examples of distributed tasks that have been used in the last two editions of a Polish programming
contest, Algorithmic Engagements, together with their intended solutions. Finally, we discuss the
challenges of grading and preparing distributed tasks.
Keywords: programming contests, distributed tasks.

1. Introduction
When looking at major programming competitions, it is easy to notice that a large number of them are very similar in design. To name a few, the IOI, the ACM ICPC, Google
Code Jam, TopCoders algorithmic track, Facebook Hacker Cup, the CodeForces competitions and many more, are all focused on small, self-contained tasks, with automated

178

A. Karczmarz et al.

judging based on testing a program on a judge-provided set of testcases and mostly


algorithmic in nature.
This model seems attractive both to the organizers and the participants. The organizers appreciate the very clear, non-subjective mechanism of judging and the automation
of judging, which means the competition can scale out easily to a larger number of
competitors. The participants also appreciate the automated judging (which means fast
results) and the objective judgment criteria (which makes the competition more fair); additionally the entry barrier to such contests is pretty low, as the introductory-level tasks
can be very simple.
If we consider programming competitions a way of educating future computer scientists and professional programmers, the model has its strengths, but also weaknesses.
Some of these weaknesses come from the very nature of the small, self-contained tasks
(which are a large part of the models attractiveness): the participants do not learn about
code maintainability and extensibility, they also do not learn anything about larger-scale
system design. These weaknesses seem to be intrinsic to the model itself; and competitions that abandon the model moving to larger or less clear-cut tasks are frequently less
successful (for example, TopCoders Marathon Match track has over 10 times less registered participants than the Algorithm track).
However, there are also areas of programming expertise that the existing competitions do not teach, which are less intrinsically tied to the model of these competitions. In
particular, the focus on algorithmic problems is not crucial to the model of the competition itself. Indeed, multiple authors already explored extending this classical model of
competitions to other fields of computer science, for example visualization and precomputation (Kulczyski etal., 2011), online algorithms (Komm, 2011), computer graphics
and cryptography (Foriek, 2013).

1.1. Distributed Programming


Distributed (and cloud) computing has gained importance quickly in the recent years.
The computing giants of today Google, Amazon, Facebook and others do not operate
on the enormous mainframes that dominated computing in the past, but on networked
farms of smaller servers. This is a model of computing that is not inherently in conflict
with the algorithmic programming contest model, but is not taught by the dominant
competitions of today; students that gained most of their programming skills through
programming competitions will be totally unfamiliar with even the basic paradigms of
distributed computing like the MapReduce framework (Dean and Ghemawat, 2008) or
the CAP theorem (Fox and Brewer, 1999).
In this article we present a framework for running a contest focusing on distributed
algorithms, developed by engineers in Googles Warsaw office in collaboration with
the University of Warsaw, and show sample problems used in the Algorithmic Engagements (Potyczki Algorytmiczne in Polish) contest ran by the University of Warsaw. The
same framework is used at the recently introduced Googles Distributed Code Jam
competition.

Distributed Tasks: Introducing Distributed Computing to ...

179

1.2. Designing a Distributed Programming Contest


The primary focus of our design was simplicity from the contestants point of view. The
introduction of a new programming paradigm, likely unfamiliar to most participants, is
clearly a challenge for the contestants, and we aimed at making the transition as smooth
as possible.
Thus, the basic interface is similar to a programming contest like IOI. The participant
submits a single program, which is compiled and executed by the framework. The same
program is run on every node (computer) available to the participant.
Obviously, the nodes need to be able to communicate in order to collaborate in computing. We decided on a protocol based on simple message-passing (send this array of
bytes to this node). The message passing methods are available to the program through
a library that is common for all problems, and provided by the framework.
We also considered using an RPC-style interface. This, however, is more complex on
an API level. A standard approach to RPC is that the programmer has to declare an interface (which will contain the remotely-callable methods). The server will just implement
the methods of this interface. On the client side, the infrastructure needs to provide a way
to generate a stub connected to some particular server; this stub will automagically have
the method calls autogenerated. The language would have to provide some way to annotate that the interface is to be treated as a remote interface, increasing the complexity of
the infrastructure implementation, and meaning more magic happening under the hood,
which in our perception decreases the comprehensibility of the system. For instance,
the stub implementation would need to make a choice of deep versus shallow copying
of the arguments, each choice potentially leading to confusion for the participants.
Let us now present the functions of our library, together with their declarations in
C++.
First, the library provides a function that returns the number of nodes on which
the solution is running, and the index (in the range [0 1]) of the node on which
the calling process is running.
int NumberOfNodes();
int MyNodeId();
The library maintains in each node a message buffer for each of the nodes, which
represents messages that are to be sent to this node. Messages are added to the buffer
through the Put-methods.
// Append value to the message that is being prepared for
// the node with id target. The Int in PutInt is
// interpreted as 32 bits, regardless of whether the actual
// int type will be 32 or 64 bits.
void PutChar(int target, char value);
void PutInt(int target, int value);
void PutLL(int target, long long value);

180

A. Karczmarz et al.

There is also a method that sends the message that was accumulated in the buffer for
a given node and clears this buffer. This method is non-blocking, that is, it does not wait
for the receiver to call Receive, but returns immediately after sending the message.
void Send(int target);
The following function is used for receiving messages.
int Receive(int source);
The library has a receiving buffer for each remote node. When you call Receive
and retrieve a message from a remote node, the buffer tied to this remote node is overwritten. You can then retrieve individual parts of the message through the Get-methods. This method is blocking if there is no message to receive, it will wait for the
message to arrive.
You can call Receive(-1) to retrieve a message from any source, or set source
to a number from [0 1] to retrieve a message from a particular source. Receive
returns the number of the node which sent the message, which is equal to source, unless
source is -1.
Finally, for reading the buffer of incoming messages, the following three methods
are provided.
// The Int in GetInt is interpreted as 32 bits, regardless
// of whether the actual int type is 32 or 64 bits.
char GetChar(int source);
int GetInt(int source);
long long GetLL(int source);
Each of these methods returns and consumes one item from the buffer of the appropriate node. You must call these methods in the order in which the elements were
appended to the message (so, for instance, if the message was created with PutChar,
PutChar, PutLL, you must call GetChar, GetChar, GetLL in this order). If you call
them in a different order, or you call a Get-method after consuming all the contents of
the buffer, the behaviour is undefined.
The serialization we decided to use is very basic, compared to models like Javas
serialization mechanisms, Pythons pickle or even Googles protocol buffer language.
Again, we preferred to err on the side of simplicity, to minimize the entry barrier this
simple language turns out to be easy enough for the simple concurrency required to solve
our problems, and is more straightforward to understand, both in terms of how big will
be the serialized message, and what is actually serialized (this, again, is the deep vs
shallow copy question).
For correctness of execution, we chose what seemed the most natural model. The
backend guarantees failure-less execution on all nodes, and requires all the instances of
the program to execute correctly, within the specified time and memory limits. Note that
the time used by the program is measured from the moment when the instances start until

Distributed Tasks: Introducing Distributed Computing to ...

181

all instances have finished execution. This assumption is justified with the following example involving two machines. The first one spends second of CPU time and then sends
a message to the second one. The second machine first waits for a message from the first
machine and then uses one second of CPU time. The total time used by the solution is
then roughly two seconds, although each instance used only one second of CPU time.
In most of programming competitions, the programs access the input data by reading from standard input. (TopCoders Algorithm contest breaks out of this by providing
the input as an argument to the function the contestant is supposed to write.) However, a large fraction of the interesting distributed problems admit a solution that runs in
() time, where is the size of the input, and is the number of nodes available
to the contestant. This implies, in particular, that no node can afford to read the whole
input (since that alone would take () time). Standard input is only accessible in a
linear fashion, so it is not feasible for providing very large input data.
The approach we chose is what is typically done for interactive tasks on competitions like IOI (see, e.g., Chvez, 2015) each problem with large inputs defines a set of
input-access methods that are available to the program, similarly to the message-passing
interface. These methods are guaranteed to return the same values on all nodes (so, each
node has access to the same view of the input). Additionally, we provide upper bounds
on the execution time of a single call to the input-providing methods.
Output is much simpler to handle (as it is often much smaller), so we went with the
standard programming contest practice of expecting the output to be provided via standard output. We expect exactly one node to produce the output, while the others should
not produce anything. This is a somewhat arbitrary decision (we could equally well
have all the nodes output the exact same data to the standard output), however, as many
solutions in practice have some sort of a master node that aggregates the work of the
other nodes, it is convenient to the contestant to have one node output the result of the
computation, and for the infrastructure not to prescribe which of the nodes it is.
As for the number of nodes we run the contestants solutions on, we chose = 100.
This is large enough that a speedup by a factor of is big enough to offset the extra time
needed for inter-node communication, and yet small enough that providing that many
nodes for judging is actually feasible.
The final issue that needs to be considered is the amount of data sent during the
communication between the nodes, both in terms of the number of individual messages
sent, and the size of those messages. Obviously, the limits here will be dependent on the
infrastructure we run the contest on. Benchmarks on our framework show that a single
message will take roughly 35ms (split between the processing time in the sender, the
actual network latency and the processing time on the receiver). This number will be
constant for messages from negligible to tens of kilobytes, and start growing linearly
when the message size goes into hundreds of kilobytes.
While in the end, to fine-tune a solution the contestant will need to understand these
patterns (for this purpose we provided the results of a few benchmarks to the contestants), we wanted the basic usecase not to require dealing with the calculations. To this
end, we introduced an upper limit on the total number (around 1000) and size (a few
megabytes) of messages a single node can send within the time limit, which roughly

182

A. Karczmarz et al.

corresponds to the total throughput it could achieve if it spent all its time on communication. This is a clear and concise way of informing the participants that if their solution
stays well within those bounds, its performance should not be significantly affected by
the communication overhead.

1.3. Distributed Contest Judging Infrastructure


From a research perspective, the most interesting challenge in preparing such a distributed programming contest is defining the exact programming model from the contestants
point of view. However, when doing it in practice, there is also a considerable amount of
engineering effort involved in providing the infrastructure to run such a contest.
In the process of preparing problems the most interesting new challenge is writing a
library that provides the input data. While in a standard programming contest the input
is just a text file, and can be generated offline in an arbitrary fashion and almost arbitrary time, in the distributed contests the requirements are much more strict. The inputproviding library needs to satisfy the following requirements:
Access to an arbitrary element.
Consistency across nodes, and across accesses.
Access times on the order of 100ns.
Ability to serve data with total size on the order of 10GB or more.
The requirements stem from the input model we chose. In particular, if we want to
allow ()-time solutions, with runtimes on the order of 15 seconds, we need the
input read by one node to be on the order of at least 107 items (which means 109 items
in total if each item is, say, two 64-bit integers, we get a total of 16GB), and we need
the node to be able to read these 107 items within 1 second (so that the input reading does
not dominate the computation).
The access times coupled with the data size mean it is infeasible to pregenerate all
the input data 10GB is too much to conveniently store in memory, while disk access (and even SSD access) is too slow. Thus, the input data is generated on the fly.
This requires using pseudo-random generators that generate a sequence of numbers, and
provide consistent and fast access to each element of the sequence (e.g., the CityHash
family of functions).
In the judging system, the challenge is the scale. Judging a single testcase for a single
solution requires, typically, 100 virtual machines. So, as an example, a deployment of
900 virtual machines on Google Compute Engine were used as the backend for the
Online Round of Googles Distributed Code Jam. We think it is interesting that cloud
computing, which is making distributed computing important as a topic of programming
competitions, is also making distributed programming competitions much easier to organize: instead of buying physical hardware to support such a competition, it is easy to
rent virtual machines and pay by the minute.
However, the real challenge in setting up a new competition type is in finding attractive problems: ones that challenge the contestants creativity and problem-solving skill,

Distributed Tasks: Introducing Distributed Computing to ...

183

without requiring significant domain knowledge (in this case knowledge of distributed
programming paradigms), and that are fun, but not tedious, to implement, once you have
the correct set of ideas. In the rest of this paper, we provide examples of problems that
in our opinion satisfy these requirements.
We start with a simple task which lets us demonstrate the basics of the framework
from the contestants point of view. The remaining tasks were presented during the Algorithmic Engagements contest; their authors are: Jakub cki, Jakub Wojtaszczyk (task
Workshop); Jakub cki (task Assistant); Adam Karczmarz (task Sabotage).

2. Sample Task Divisors


In this task we are to count the number of divisors of a given positive integer 1018.
Input
In this task the input data is provided via the standard input. The only line of the standard
input contains .
Output
Your program should print exactly one line to the standard output containing one integer:
the number of divisors of .

2.1. Solution
The easiest (sequential) solution that we can come up with is to check all candidates for a
divisor up to and their counterparts of the form
. A sample C++ code follows.

int main() {
long long n;
int divisors_num = 0;
cin >> n;
for (long long d = 1; d * d <= n; ++d) {
if (n % d == 0) {
++divisors_num;
if (n / d != d)
++divisors_num;
}
}
cout << divisors_num << endl;
}
Probably this is not the fastest sequential solution for this problem. We will, however,
focus on how to speed it up by performing the computations using nodes (machines).

184

A. Karczmarz et al.

A natural idea is to partition the set of possible divisors and let each of the machines look
through each of the parts.
One way of performing this partition is as follows: machine 0 gets to check the
candidates 1 1 + 1 + 2 machine 1 gets to check the candidates 2 2 +
2 + 2 etc. To make it work, it suffices to change the for-loop from the above
code to:
for (long long d = 1 + MyNodeId(); d * d <= n; d +=
NumberOfNodes()) {
In the end we need to aggregate the partial results. Let us select any of the machines
(say, machine 0) as an aggregator. We just need to add code to be executed on each of
the machines that sends the partial results from machines with positive numbers to the
machine number 0.
if (MyNodeId() > 0) {
PutInt(0, divisors_num);
Send(0);
} else { // MyNodeId == 0
for (int node = 1; node < NumberOfNodes(); ++node) {
Receive(node);
divisors_num += GetInt(node);
}
cout << divisors_num << endl;
}
}
The final solution works in ( ) time, i.e., this is the maximum of the time
complexities of the instances running on each of the machines.

3. Task Workshop (2014)


During an algorithmic workshop students are sitting in a circle and solving problems.
Whenever someone comes up with a solution to a problem, he or she shares the idea with
his or her two neighbours (which takes exactly one minute), and then they pass it to their
neighbours (which also takes exactly one minute), and so on.
If Johny comes up with a brilliant solution at quarter to twelve, what time will Chris
hear about it? How many minutes does it take for a solution to reach from Kate to Tom?
That is the kind of queries your program has to answer.
Input
The input data is provided by an interactive library. Your program can call six functions
from the library:

Distributed Tasks: Introducing Distributed Computing to ...

185

int NumberOfStudents(): returns the number of students participating in


the workshop (3 109). The students are numbered with consecutive integers
from 1 to .
int FirstNeighbour(int i): returns the number of the first neighbour of the
-th student (1 ). The students have a hard time distinguishing left from
right, therefore they prefer to call their neighbours in the order of their numbers.
That is, the first neighbour of a given student always has a number smaller than his
of her second neighbour.
int SecondNeighbour(int i): returns the number of the second neighbour of
the -th student (1 ).
int NumberOfQueries(): returns the number of queries your program has to
answer (0 200). The queries are numbered with consecutive integers from
1 to .
int QueryFrom(int i): for the -th query (1 ), returns the number of the
student who came up with a solution.
int QueryTo(int i): for the -th query (1 ), returns the number of the
student willing to know when he or she is going to hear the solution.
Output
Your program should print exactly lines to the standard output. The -th line should
contain the answer to the -th query, i.e., the number of minutes it takes for a solution to
reach from one student to the other.

3.1. Solution
In the problem a cycle is specified using an oracle which for a given vertex returns its
two neighbours. The neighbours are returned in an order that is not necessarily consistent with the order of the vertices on the cycle. A number of queries are given, each
consisting of two vertices, and the task is to compute for each query the length of the
shortest path between the two vertices.
The first step of the model solution is to select a subset of vertices, which we call
checkpoints. The checkpoints include all the vertices which are part of any query and additionally some number of randomly selected vertices. Later we discuss how to choose
this number. After the checkpoints have been selected, each checkpoint is randomly assigned to some machine (node). All the random choices are made with a deterministic
pseudorandom number generator so that all machines select the same checkpoints without needing to communicate.
In the second step each machine processes the checkpoints assigned to it. Starting
from a checkpoint the process running on the machine traverses the cycle in both directions until it reaches (at both ends) any other checkpoints (they might be assigned to a
different machine). While traversing the cycle, the process counts the number of visited
vertices. Finally, it sends to the first machine a list of statements of the following form:
the distance between the checkpoints and equals and there is no other checkpoint
between them.

186

A. Karczmarz et al.

The third step is run only on the first machine. First, it receives messages from all the
other machines. Using information from the messages, the machine computes the order
of checkpoints on the cycle and the distance between each two neighboring checkpoints.
After linear-time processing of this information, it is easy to answer each query in constant time.
We are left with the problem of choosing the number of checkpoints. Recall that
1
denotes the number of machines. Each machine processes a random fraction of
of the

checkpoints which makes the expected running time of each machine ( ). However,
from a theoretical point of view, this kind of a statement is worthless. Consider an imaginary situation in which we need to perform computations that take ( ) total time, and
we pick a random machine to perform all of it. Then each machine spends ( ) time
1
with probability
, which gives exactly ( ) expected time for each machine,
just like in the case of our solution. At the same time, we are interested in the running
time of the slowest machine, which is clearly still ( ) .
For this reason, we study the performance of our solution experimentally. Luckily, the running time depends mostly on the size of the input data, not on its structure.
Our simulations show that with randomly selected checkpoints, the longest running
) expected time, which is consistent
machine uses ( lg ) time, compared to (

with a theoretical analysis in (David and Nagaraja, 2003, p. 135). It is possible to reduce
the variation between machines by increasing the number of checkpoints. In practice,
our solution which always selects 10 000 checkpoints is about 152 times faster than
the one that selects checkpoints.

3.2. Tests
It seems that virtually any nontrivial test is sufficient to distinguish solutions based on
an incorrect algorithm. However, a bit more care is required to distinguish solutions
that are correct but may be too slow e.g. a variant of the model solution that selects
as the checkpoints only the queries endpoints and the vertices 1 2 instead of
randomly selected vertices. To make such solutions exceed the time limit we need to pay
attention to keep large contiguous fragments of the cycle without any query vertex and
leave a large fragment of the initial 1 2 cycle around the vertex 1 unaltered.
The remaining part of the cycle is permuted either by performing a circular shift on the
binary representations of vertex numbers or by xor-ing them with some fixed number.
This method allows (1)-time calculation of vertex neighbours and produces a cycle
looking sufficiently random to make it difficult to come up with a clever incorrect solution exploiting this particular structure of the test.

4. Task Assistant (2014)


The life of an assistant is not easy. Not only did the professor order him to write a terribly
long review, she also requested some corrections today.

Distributed Tasks: Introducing Distributed Computing to ...

187

Pushing keys of a keyboard is very tiring, so the primary goal of the assistant is to
push keys as few times as possible, while correcting the review. The keyboard that he is
using with a single click allows him to delete a character in the review, change a character to a different one or insert one character anywhere in the review.
To make things worse, the assistant has a very peculiar sense of esthetics. He likes
letters from the beginning of the alphabet (like a, b or c), but is disgusted by the letters from the end of the alphabet (in particular, y and z). Each time he presses a key
and changes a letter that comes earlier in the alphabet to a letter that comes later (for
example, m to p), he suffers an esthetic shock, which is devastating for him. Because of
that, the secondary goal of the assistant is to minimize the number of such changes.
Input
The first line of the standard input contains two integers and (1 100 000),
that specify the lengths of the first and the second version of the review. The following
two lines contain the two versions themselves. Each review consists only of lowercase
letters.
Output
Your program should output a single line containing the minimal number of keyboard
presses that the assistant has to perform in order to correct the review, followed by the
minimal number of esthetic shocks that he will suffer.

4.1. Solution
The problem considered in this task is a variant of the well-known edit distance problem.
Our solution will refer to the classical dynamic programming approach to this problem,
which has been described in a number of textbooks (see, e.g., Cormen etal., 2009). The
solution that we obtain can be easily extended with minimizing the number of esthetic
shocks. In short words, it suffices to, instead of storing only the edit distances, store integer pairs that describe the edit distance and the number of esthetic shocks, and compare
them lexicographically.
Denote by 1 the characters in the first version of the review and by
1 the characters in the second version. Our goal is to compute a two dimensional matrix , where ( ) contains the minimum number of changes that
the assistant has to perform in order to change 1 into 1 . Just like
in the edit distance problem, the values (1 ) and ( 1) can be computed in a
straightforward way, whereas for 2 and 2 , ( ) can be computed in
constant time, given ( 1 ), ( 1) and ( 1 1).
Assume that the topmost row of matrix contains elements (1 ) and the leftmost column contains ( 1). Partition the matrix into stripes consisting of
consecutive columns (for simplicity, we assume that is divisible by ), where is the
number of machines available. Each machine is responsible for filling in the entries of
in one stripe. Let the -th machine (for 2 f1 g) be responsible for the -th
stripe from the left. See Fig. 1 for illustration.

188

Assume that the topmost row of matrix D contains elements D(1, ) and the
leftmost column contains D(, 1). Partition the matrix into M stripes consisting
of l/M consecutive columns (for simplicity, we assume that l is divisible by M ),
where M is the number of machines available. Each machine is responsible for
A. stripe.
Karczmarz
et machine
al. (for i {1, . . . , M })
filling in the entries of D in one
Let the i-th
be responsible for the i-th stripe from the left. See Fig. ?? for illustration.

Figure of
1: The
process ofthe
computing
D. assigned
Stripes assigned
to different
Fig. 1. The process
computing
matrixthe
.matrix
Stripes
to different
machines have
machines have been marked with different shades of gray. The numbers inside
been marked with
different
shades
of
gray.
The
numbers
inside
the
matrix
specify
the phase
the matrix specify the phase number, when the respective part of the matrix
is
number, whencomputed
the respective
part of the matrix is computed (see below).
(see below).
The first machine fills in the first (leftmost) stripe, starting from the topmost
row. Consider the rightmost column in the first stripe. Observe that the con-

The first machine


in the
first (leftmost)
stripe,
from
tents offills
this column
is everything
the second machine
needs starting
to know, in order
to the topmost row.
fill in its stripe. The entries in the rightmost column of the first stripe are filled
Consider the rightmost
column
in
the
first
stripe.
Observe
that
the
contents
of this colin by the first machine from top to bottom, and as they are being computed,
machine sends
them to needs
the second
then
umn is everything the
thefirstsecond
machine
tomachine.
know,The
insecond
ordermachine
to fill
in its stripe. The enfills in its stripe and sends the contents of the cells in the rightmost column of
tries in the rightmost
column
of the
first
its stripe
to the third
machine,
andstripe
so on. are filled in by the first machine from top
The correctness of this approach should be clear. However, we need to
to bottom, and as improve
they are
being
computed,
first machine
sends
it a little bit, in order to makethe
it efficient.
Clearly, each
machinethem to the second
requires O(kl/M ) time to fill in its cells. However, all machines (except for the
machine. The second
machine
then
fills
in
its
stripe
and
sends
the
contents of the cells in
last one) send k messages, each containing a single number. This may be very
inefficient,
but stripe
can be fixed
as a machine
may sendand
the contents
the rightmost column
of its
to easily,
the third
machine,
so on.of cells
in batches, each containing b numbers, thus reducing the number of messages
to k/b.
Thisapproach
obviously doesshould
not impactbe
the clear.
running time
of each machine.
The correctness
of this
However,
we need to improve it a
However, there is one more efficiency aspect that we should take care of.
little bit, in order to
make
it efficient.
requires
Namely,
we need
to assure thatClearly,
the machineseach
do not machine
wait long for the
numbers () time to
they need to have in order to perform computation. If each machine sends
fill in its cells. However,
all machines (except for the last one) send messages, each
containing a single number. This may be very
inefficient, but can be fixed easily, as a
12
machine may send the contents of cells in batches, each containing numbers, thus
reducing the number of messages to de. This obviously does not impact the running
time of each machine.
However, there is one more efficiency aspect that we should take care of. Namely,
we need to assure that the machines do not wait long for the numbers they need to have
in order to perform computation. If each machine sends the contents of the rightmost
column after filling in its entire stripe (i.e. sends batches of = messages), then our
solution becomes essentially sequential. On the other hand, we know that = 1 is also
not a good choice, for performance reasons.
Let us analyze how to pick a good value of . For the analysis, assume that all the
machines are perfectly synchronized, that is, in each time unit a machine can fill in exactly one cell of its stripe (or wait for the data it needs to continue working). Consider
now a phase of exactly time units. Since each stripe has width , the first machine sends the first message to the second machine exactly after the first phase. In the
second phase, the second machine starts working (fills in the first rows of its stripe)
while the first one keeps on working on the following rows. From the second phase, the
second machine no longer needs to wait, as it receives the necessary data exactly the
moment when it needs it. In general, the -th machine starts to work in the -th phase
after ( 1) = () time units. Thus, the -th machine starts after ()
time units and then works for () time units. Hence, all the machines finish
within ( + ) time units and send () messages each.

Distributed Tasks: Introducing Distributed Computing to ...

189

By setting = bc we assure that the waiting time is dominated by the computing


time, which means that our solution parallelizes the single-machine solution in a perfect
way. At the same time, the total number of messages sent is moderate (( 2)).

5. Task Sabotage (2015)


The city of Megabyteopolis was built upon a large lake and consists of a number of isles
connected with bridges. The bridges may run above other bridges.
A group of saboteurs wants the current president Byteasar not to be reelected. They
plan to impact the public opinion by exposing Byteasars administrations helplessness
in the case of a major emergency. Specifically, they decided to blow up one of the bridges (they cannot afford blowing up more). The sabotage could be considered successful
only if there was no other way between the isles previously connected by the destroyed
bridge. Your task is to find the number of bridges that the saboteurs should consider
when working out the details.
Input
int NumberOfIsles(): returns (1 200 000) the number of isles constituting the city of Megabyteopolis. The isles are numbered 0 through 1.
int NumberOfBridges(): returns (1 108) the number of bridges in
the city. The bridges are numbered 0 through 1.
int BridgeIntA(int i): returns the first isle connected by the bridge .
int BridgeIntB(int i): returns the second isle connected by the bridge .
Output
The output should contain a single integer the number of bridges whose blowup could
result in the sabotage being considered successful.

5.1. Solution
In this task we are asked to solve a basic graph problem: for a given undirected graph
= ( ) we need to compute the number of bridges. A bridge is defined here as an
edge of whose removal results in an increase of the number of connected components
of . Denote by () the set of bridges of . A textbook algorithm (e.g., Sedgewick,
2002) for computing () is based on an extension of the depth-first search (DFS) algorithm and runs in ( + ) time. The number of vertices in our graph is quite small,
i.e., the bound on the order of 105 is typical for graph tasks even in the traditional, nondistributed setting. The number of edges in our case can be, however, much larger.
Unfortunately, DFS is not an algorithm that can be parallelized easily. Nevertheless,
we do not need to entirely abandon the idea of using DFS: our strategy is to use the multiple machines to reduce our problem instance to an instance with only () edges. In
such a reduced instance, we use DFS to find the bridges.

190

A. Karczmarz et al.

Definition 1. Consider a graph = ( ). We define a bridge certificate of to be a


set such that for any , (( [ )) = (( [ )).

As a result, replacing a subset of edges of with its bridge certificate does not affect
the set of bridges of . We are going to use the bridge certificates to detect and remove
edges of . The following lemma describes a construction of a bridge certificate. For
completeness we give its proof in the Appendix.

Lemma 1. Let = ( ) and = j j, = jj. Then there exists a bridge certificate


of such that jj 2 which can be computed in (+) time.
By Lemma 1, we can take any subset 0 of edges of , find a bridge certificate of
( 0) and replace 0 in with 0 in (+j0j) time. We call this step a reduction with respect to 0.
It turns out that we can easily perform the reductions in a parallel fashion. For simplicity, first assume that we have only two machines, i.e., = 2. We partition the
edge set into two sets 0 1 of roughly equal size. The machine , for = 0 1,
performs the reduction step on the set , obtaining a certificate of size at most 2,
in (+jj) time. Next, machine 1 sends the set 1 to machine 0. In the last step,
machine 0 runs DFS to find the set (( 0 [ 1)). This, however, takes only ()
time, as j0 [ 1j 4. By the definition of a certificate,
() = (( 0 [ 1)) = (( 0 [ 1)) = (( 0 [ 1))
This concludes that indeed this approach finds all the bridges of .
In order to develop a distributed algorithm using 2 machines, we perform
multiple reduction phases. In the first phase, the set of edges is partitioned among the
machines, and each machine computes a certificate of the edges assigned to it. In
the following phases the certificates are merged in pairs: two certificates produced in
the previous phase are sent to a machine that takes their union and computes the certificate of the resulting graph.
Let us describe this process formally. Assuming that the machines are numbered 0
through 1, we split the input edge set arbitrarily into parts 0 1, each
of size (). Our distributed algorithm runs in = dlog2e + 1 phases numbered
0 through 1. In the -th phase ( = 0 1) only the machines with identifiers
divisible by 2 are active and actually do perform some work. With each active machine
we associate two sets , ( ) whose contents depend on the phase number
. Before the -th phase:
is a bridge certificate of the graph
= ( [ +1 [ [ +2 1)
In the above we set + = ; if + .
If = 0 then = . Otherwise, j j 4.

After the -th phase the set is a bridge certificate of and j j 2. Note that
it follows that after the phase 1, 0 is a bridge certificate of and j0j = ().

191

Distributed Tasks: Introducing Distributed Computing to ...

At that point the machine 0 runs DFS on ( 0) to compute the set of bridges of in
() time.
It remains to show how to implement the phases so that the invariants imposed on the
sets are satisfied. Before the first phase we set = . Assume that the phase
1 has been completed. We perform a reduction of Lemma 1 on the set in order to
obtain the set . This takes ( + j j) time, which is () for 0 and ( +
) if = 0. The last step is to initialize the sets before the next, ( + 1)-th phase.
To do that, for each divisible by 2+1, we set = [ +2 if + 2 and
= otherwise. As for all , jj 2, clearly we now have j j 4. To implement
this step, the machine + 2 sends the entire set +2 to the machine . This requires a
single message of () bytes. Fig. 2 depicts the phases of our distributed algorithm.
In each phase every machine remains idle or sends () bytes, or receives ()
bytes. Consequently, the first phase takes ( + ) time on each machine and
each of the 1 remaining phases runs in () time on each machine. Thus, the time
complexity of this solution is ( + log).

5.2. Tests
The library providing the test data had to be robust enough to serve graphs with large
edge sets and nontrivial 2-edge-connected components (i.e., connected components of
formed after removing all the bridges), given limited time and space. It seems that a
hard test case is a graph with a maximum number of edges and possibly large number
of bridges. In such a case at least some of the 2-edge-connected components should be
very dense.

Ph. 3

Ph. 2

Ph. 1

Ph. 0

X0
Y0
X0

X4

Y0

Y4

X0

X2

X4

X6

Y0

Y2

Y4

Y6

X0

X1

X2

X3

X4

X5

X6

E0

E1

E2

E3

E4

E5

E6

Fig. 2. The phases of the distributed algorithm when = 7. In this case = 4 phases are
Figure 2: The phases of the distributed algorithm when M = 7. In this case
performed. The blue arrows illustrate the communication between the machines in the corK = 4 phases are performed. The blue arrows illustrate the communication
responding phases.

between the machines in the corresponding phases.

components of G formed after removing all the bridges), given limited time and
space. It seems that a hard test case is a graph with a maximum number of
edges and possibly large number of bridges. In such a case at least some of the

192

A. Karczmarz et al.

The infrastructure for generating test graphs provided a general graph interface along
with a few specialized implementations (a vertex, a path, a cycle, a clique, a pseudorandom graph, a set of loops) that could serve the edges in (1) time with constant
space consumption, regardless of the graph size. As an example, a cycle on vertices
numbered 0 through 1 can be represented with a single integer : when asked for the
cycles -th edge, we just return ( ( + 1) mod ).
Such graphs could be then combined into larger and more sophisticated graphs by
unions and direct sums and also extended by adding specified edges, which were typically used to ensure the desired structural properties of the served graph. For example,
this allowed to easily generate a tree of size 100 with each vertex replaced with a random
2-edge-connected graph with 1000 vertices and between 100 000 and 500 000 edges.
Such a graph had on the order of 107 edges in total, 99 bridges and could be represented
with the number of bytes on the order of 102. At the highest level, the vertices were assigned random identifiers, whereas the list of edges was randomly permuted.
The size of the in-memory representation of each test cases was () per machine
and the sophistication level of the served graphs was limited only by the need to return
the requested edge in time on the order of 100ns.

6. Conclusions
We described a novel format of programming competitions, aimed at familiarizing students with an increasingly important area of computer science design of distributed
algorithms. While there is a considerable engineering effort involved in preparing the
backend for such a competition, we hope that an increasing number of competitions
(maybe including IOI in the future) will feature tracks or problems of a distributed nature, to reflect the industrys shift toward cloud-based and distributed computing.

References
Chvez, L.H. (2015). libinteractive: a better way to write interactive tasks. Olympiads in Informatics, 9, 314.
Cormen, T.H., Leiserson, C.E., Rivest, R.L. Stein, C. (2009), Introduction to Algorithms. MIT Press.
David, H.A. Nagaraja, H.N. (2003). Order Statistics (3rd Edition). Wiley.
Dean, J. Ghemawat, S. (2008). MapReduce: simplified data processing on large clusters. Communications of the
ACM 50th anniversary issue: 19582008, 51(1), 107113.
Foriek M. (2013). Pushing the boundary of programming contests. Olympiads in Informatics, 7, 2335.
Fox, A. and Brewer E. (1999). Harvest, yield and scalable tolerant systems. In: Proc. 7th Workshop Hot Topics
in Operating Systems (HotOS 99). IEEE CS, 174178.
Komm D. (2011). Teaching the concept of online algorithms. Olympiads in Informatics, 5, 5870.
Kulczyski, T., cki, J., Radoszewski, J. (2011). Stimulating students creativity with tasks solved using precomputation and visualization. Olympiads in Informatics, 5, 7181.
Sedgewick, R. (2002). Algorithms in C++, Part 5: Graph Algorithms. Addison-Wesley Longman Publishing
Co., Inc., Boston.

Distributed Tasks: Introducing Distributed Computing to ...

193

A. Karczmarz (1990), PhD student at Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Poland, jury member of
multiple programming contests organized by University of Warsaw,
coorganizer of Algorithmic Engagements 2015. In his research he focuses on algorithms and data structures.
J. cki (1986), postdoctoral researcher at Sapienza University of
Rome, Italy, IOI Scientific Committee elected member, appointed
chair for 2016, responsible for task selection at Algorithmic Engagements for many years, former head organizer of Polish Training Camp.
In his research he focuses on graph algorithms.
A. Polak (1991), PhD student at Department of Theoretical Computer
Science, Faculty of Mathematics and Computer Science, Jagiellonian
University, Krakw, Poland, judge at the ACM Central Europe Regional Contest in 2012, 2013, and 2014. His research interests lie in
algorithms, complexity theory, and computer vision.
J. Radoszewski (1984), assistant professor at Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Poland, and
Newton International Fellow at Kings College London, UK, chair of
the jury of Polish Olympiad in Informatics, cochair of the Scientific
Committee of CEOI2011 in Gdynia, former member of Host Scientific Committees of IOI2005, CEOI2004, BOI2008, and BOI2015.
His research interests focus on text algorithms and combinatorics.
J.O. Wojtaszczyk (1980), Staff Software Engineer at Google, Warsaw,
judge at the ACM ICPC World Finals in 2011, 2012, 2013, 2015 and
2016, coorganizer of the Google Code Jam since 2012, main organizer
of the Distributed Code Jam. The primary focus of his engineering
work is around cluster management.

dix: Proof
Appendix:
of Lemma
Proof
?? of Lemma ??

?. Let H = (V,
Lemma
E) and??.
n =Let
|V H
|, m
==
(V,|E|.
E) and
Thenn there
= |V |,exists
m = a|E|.
bridge
Then there exists a bridge
X of H such certificate
that194
|X| X2nofwhich
H such
canthat
be computed
|X| 2nA.
in
which
O(n
can
+
m)
be
time.
computed
in O(n + m) time.
Karczmarz et al.

compute theProof.
setAppendix:
X We
in the
compute
following
set XFirst,
in 1the
compute
following
some
way.spanFirst, compute some spanProofthe
ofway.
Lemma
n Appendix:
there exists a bridge
Proof
Lemma
F (we identify
ning
it with
forest
aFset(we
ofof
its
identify
edges)it of
with
H using
a??
set of
any
itsgraph
edges)search
of H using any graph search
ted in
O(n + m) time. Proof of Lemma ??

Appendix:
This
takes O(n
algorithm.
+ m) time.
ThisThen,
takes compute
O(n + m)some
time.spanning
Then, compute
forest F some
spanning forest F
Lemma
??.of Let
there
exists
a2n
bridge
H = (V, E) and
n = |V |, m = |E|. Then

,
E
\
F
).
Finally,
H
set
=
(V,
X
=
E
F
\
F

).
F
Finally,
.
Clearly,
set
|X|
X

=
2n
F

and
F
.
X
Clearly,

E.
|X|

and aXbridge
E. certificate
Lemma 1. Let = ( ) and = j j, = jj. Then there exists
, compute some spancertificate
X
of
H
such
that
|X|

2n
which
can
be
computed
in
O(n
+
m)
Lemma
??.
Let
H
=
(V,
E)
and
n
=
|V
|,
m
=
|E|.
Then
there
exists
atime.
bridge
wsing
prove
that
X
is
We
indeed
now
prove
a
bridge
that
certificate
X
is
indeed
of
H.
a
bridge
Let
Y
certificate

V
.
of
H.
Let
Y

of such that jj 2 which can be computed in (+) time. V V .


any graph search
certificate
X graphs
of let
H such
thatthat
|X|

which
can
be(V,
computed
in
O(n
us
show
that
First,
the
usHshow
theY2n

)graphs
and HH
XEcompute
YY) )have
and
H2+=m)
(V,time.
X Y ) have
1 =X(V,
2way.
1==(V,
meProof.
spanning
forest F
We compute
the
set
inEthe
following
First,
some
spanProof.
We
compute
the
set

in
the
following
way.
First,
compute
some
connected
components.
the
same
connected
Clearly,
if
components.
there
exists
Clearly,
a
path
u
if

there
v
in
exists
H
a
path
u
spanning
v in H2 forest
ning
2n
and
X
E. identify
forest
Fcompute
(we
itset
with
a set
offollowing
its edges)way.
of HFirst,
usingcompute
any 2graph
search
Proof.
We
the
X
in
the
some
span a(we
with
a in
setH
ofof
edges)
of
usingif any
graph
search
algorithm.
hH.
u ning

then
Hpath
, identify
as
uH
is
vitwith
aexists
subgraph
,itsas
H
. 2Conversely,
isof
asome
uof graph
H
if u This
ma
??vforest
2 it
1H
1 . 0 Conversely,
Let
Yexists
This
VFin
(we
V
.1identify
algorithm.
takes
O(n
+
m)
time.
Then,
compute
spanning
forest
F 0
a set
of 1its
edges)
Hsubgraph
using
any
search
of
=such
takes

(
+)
time.
Then,
compute
some
spanning
forest

n ). Fi.
Then
there
exists
a
bridge

by
a
path
P
,
then
any
edge
by
a
(a,
path
b)
P

,
P
then
\
Y
any
such
edge
that
(a,
b)

P
\
Y
that
connected
in
and
H
v
are
connected
in
H
1
of
??set
HProof
E
Y 1Lemma
)\ have
H(V,=X(V,
F ).takes
Finally,
X =time.
. Clearly,
|X| some
2n spanning
and X forest
E. F
2of=
algorithm.
This
O(n
+ m)
Then,
compute
0 F F

nally,
set

.
Clearly,
jj

2
and

.
computed
in
O(n
+
m)
time.
|,path
m
=
|E|.
Then
there
exists
a
bridge
\VaX
can
be
replaced
(a,
b)

E
by
\
a
X
path
can
a
be

replaced
b
contained
by
a
entirely
path
a

in
F
b
contained
(recall
entirely
in
F
(recall

(V,
vprove
in \HFthat
X is indeed
Y XVE.
V.
2). Finally,
ofWe
Hunow
=
E
set Xa=bridge
F Fcertificate
. Clearly, of
|X|H. Let
2n and
We
prove
that
=of
isthere
indeed
aYbridge
certificate
of
.
Let
. First, let
can
beforest
computed
in
+is|E|.
m)
time.
H
=
(V,
E)
and
nof
=that
|,O(n
mX
=
Then
exists
a
bridge
ahich
spanning
that
F
H).
is|V
anow
spanning
forest
H).
H
.
Conversely,
if
u
First,
let
us
show
the
graphs
H
(V,
E

)
and
H
=
(V,
X

Y
)
have
1
We
now
prove
that
indeed
a
bridge
certificate
of
H.
Let
Y

V
V.
1
2
First, compute some
spanus
the

=ein
(
G+
[with
) )Now
and

=(V,
v[in
)H)have
have assume
the same conHgraph
such
that
|X|
G
2n
begraphs
computed
O(n
m)
time.
G,
define
For
show
awhich
e that
graph
asthat
Gcan
with
G,graphs
define
theClearly,
edge
G1
e(V,
removed.
as
the
assume
edge
eu(
removed.
Now
2=
,ofb)

P
\
Y
such
that
the
same
connected
components.
if
there
exists
a
path

First,
let
us
show
the
H
=
E
Y
and
H
X
Y
2
2
H using
anyFirst,
graph
search some span- 1
llowing
way.
compute
is
a
bridge
in
that
H
(u,
v)
is
a
bridge
in
H
,
i.e.,
(u,
v)

B(H
).
Then,
,
i.e.,
there
(u,
v)
is

no
B(H
path
).
u
Then,

v
there
is
no
path
nected
components.
Clearly,
if
there
exists
a
path

in

then
a
path
1 v exists
1 H
12 is a subgraph
d then
entirely
in Fconnected
(recall
aset
path
u
inway.
H1search
, First,
as
of 1H1a. path
Conversely,
the
same
components.
Clearly,
if there
exists
u 2 v ifin uH2 u v exists
some
spanning
forest
F graph
of
itsthe
edges)
H(u,
using
any
ute
Xofin
in
the
following
compute
some
spanu, and
v).
As
H

v)

(u,
is
a
v).
subgraph
As
H

of
(u,
H
v)

is
(u,
a
v),
subgraph
there
is
of
also
H
no

(u,
v),
there
no a path
H
in

,
as

is
a
subgraph
of

.
Conversely,
if

and

connected
1 by
2
2 , as
1then
1
2 by
1a
aH
path
P
any
edgesearch
(a,of
b) H
1P
Y are
such
thatif uisinalso
v
are
connected
Hof
,H
then
a with
path
u1set

vinits
exists
in
is
subgraph
. \Conversely,
1edges)
Appendix:
Proof
Lemma
??
1H
2
y,identify
|X|
2n
andsome
1spanning
E.
Then,
compute
forest
Fv).
it
aX
of
of
using
any
graph

(u,
v).
Moreover,
H

and
(u,
H
Moreover,
have
the
same
H
and
connected
H
have
the
same
connected
v
in
H
path
u

v
in
H
, then
any
edge
)path
2 2P
,anthen
such
that
) b)
22Pnin
be that
replaced by a path
2 1(
1 ((a,
emoved.
assume
(a,
b)
2vNow
E
\m)
X
can

b any
contained
(recall
of
a apath
edge
\YFcan
such
and
are
connected
in
1 by
cate
H.
Let
Ytime.
Vbe
replaced
V .Hcompute

F
.O(n
Clearly,
|X|
2n
and
X
by
E.
akes
+
Then,
some
forest
Fentirely
and
consequently
and
consequently
ts
and
thus
(u,
components
v)

X
E)
Yand
.and
Thus,
thus
(u,
v)
spanning
X
B(H

Y
Thus,
(u,
v)
B(H
2 ).b
2) F
here
is
no
path
u

contained
entirely
in
(recall
that

is
a
spanning
forest
of
).
emma
??.
Let
H
=
(V,
n
=
|V
|,
m
=
|E|.
Then
there
exists
a
bridge
that
F
is
a
spanning
forest
of
H).
(a,
b)

E
\
X
can
be
replaced
by
a
path
a
contained
entirely
in
(recall

Hcertificate
(V, Xof
YF)have
ridge
Let
V |X|
V . 2n and X E.
).and
Finally,
=)H.
F . Y).
Clearly,
2 = set
B(H
).
define
B(H
1G,
2G
u,
v),2that
there
isB(H
also
no
graph
,
withe the
edge
+removed.
Now assume that ()
the
of
H
such
that
|X|
2n
which
can
beascomputed
in
m) time.
For
graph

e)define
as
Gof
with
removed.
Now
assume
Fais
is
au
spanning
forest
of
H).
exists
aX
path

vFor
ina(V,
H
=
(V,
E
Y
)
and
H
=

Y
have
ertificate
that
X
indeed
a
bridge
certificate
H.
Let
Yedge
Then,
V
VuH
.O(n
2X
2
, suppose
that
(u,
Finally,
v)a
B(H
suppose
that
(u,
v)

B(H
Then,
u(
and
vB(H
are
connected
).
in
and
,isbut
vno
are
connected
in
H2, but
2 ).
2 Then,
2is
eaph
theofsame
connected
that
(u,
v)
is
a
bridge
in
H
,
i.e.,
(u,
v)

).
there
no
path
u
v in
is
bridge
in

,
i.e.,
)
2

(
).
Then,
there
path

( ). As
For
a
graph
G,
define
G

e
as
G
with
the
edge
e
removed.
Now
assume
1
1
1 Y ) have
1
H1compute
.graphs
Conversely,
if X
uuEin
rly,
ifexists
there
exists
a(u,

H
w
that
the
H
=
(V,
1the
Yvis
)in
and
=way.
(V,
X
2H
1 path
2 (u,
oof.
We
the
set
following
First,
compute
some
span
v).
As
H
a
subgraph

v).
of
As
H
,
H
(u,
is
v)
a

subgraph
E

Y
.
of
H
,
(u,
v)

E Y .( ).
v
in
no
H
path
u

v
exists
in
H
2
2, subgraph
2 v)of
1
2there
1
)
and
consequently
H

(u,
v).
As
H

(u,
v)
is
a
subgraph
of
H
(u,
v),
there
is
also
no
in
H
2
that
(u,
v)
is
a
bridge
in
H
i.e.,
(u,
B(H
).
Then,
there
is
no
path
u

v
(
)
is
a
(
),
is
also
no
path

in

1
2
1
1
2H1 . that
1 u 1 v in H
2
dge
(a,
b) F (we
P \Y
such
a subgraph
of
Conversely,
if
ted
components.
Clearly,
if there
exists
path
2wisforest
2 (u,
ng
identify
it
with
ano
set
ofuits
edges)
of H
HH
using
graph
search
v).
Assume
contrary

v).
Assume
the
contrary
that
no
path
Let
uus
show
v (u,
exists
that
in
H
path
uasubgraph

vand
exists
inthe
H1any
1is

v).
Moreover,
H
the
same
connected
path
uentirely
v(u,
in
HF
edge
v).
As
H

(u,
v)
a(u,
of
(u,
v),
there
is also
no
in any
H
Moreover,

and

have
the
connected
components
and
thus
(
)
2
[.
2H
1 same
2 have
1in
2a
1
ntained
in
(recall
1
2
,
then
(a,
b)

P
\
Y
such
that

v
exists
H
,
as
is
subgraph
of
H
.
Conversely,
if
u
1
1P
takes
O(n
+
m)
Then,
compute
spanning
forest
Fa u v path in
be
such
aThis
path.
and
let
Ifbut
P
P2be
X(u,
such
v).
Ytime.
,aXthen
path.
P Thus,
Ifwould
(u,
be
X

asome
Yu ,B(H

then
v 2path
Pthe
would
in
be
egorithm.
connected
in
H
,in
)
and
consequently
components
and
thus
(u,
v)

Y
.
v)

2Thus,

Moreover,
H
and
H
have
same
connected
path
u

v
H

) in
2F
edge
(2) (a,
andb)consequently
(2).
2
2(
th
entirely
1)
ain
by
aFpossible.
path
Pv),
,(
then
any
P1Hence,
\ Y |X|
such
that
ted
Hbis
1 contained
=1
\
).
Finally,
set
Xthere
=(recall
F exist

F
Clearly,

2n
and
X E.
,HB(H
which
not
(u,
Hence,
which
is
not
possible.
some
edges
(a,
there
exist
P )such
some
edges (a, b) P such
H
2
of
,1(V,
(u,
v)
E
YFinally,
.thus
) E
B(H
).
(u,
v)
X

Y(
..entirely
Thus,
(u,
v)
b)
B(H
2and
2 and
suppose
that
) 2
(
).(recall
Then,
and consequently
are
connected in 2, but no
ge
eHcomponents
removed.
Now
assume
nWe
be
replaced
by
a
path
a

b
contained
in
F
2

now
prove
that
X
is
indeed
a
bridge
certificate
of
H.
Let
Y

V
H
,
there
exist
paths
, V2there
exist paths
E
\
X
\
{(u,
that
v)}.
(a,
As
b)

(a,
E
b)
\

X
/
F
\
{(u,
and
v)}.
(a,
b)
As

/
(a,
F
b)

/
F
and
(a,
b)

/
F
Assume
contrary
Finally,
that
(u,
v) assume
B(H
Then,
u
and
visare
connected
in
,. but
) of
suppose
B(H
B(H
2 ).
1the
2 ).
hen,
there
is
no
path
u

v
path

exists
in

(
).
As

a
subgraph
of

,
(
) 2 [ . Let us

with
the
edge
e
removed.
Now
ning
forest
H).

2
2
1
rst,
let
us
show
that
the
graphs
H
=
(V,
E

Y
)
and
H
=
(V,
X

Y
)
have
Q
and
Q
from
a
to
b
in
both
spanning
from
a
forests
to
b
in
F
both
and
spanning
F
,
correspondingly.
forests
F
and
At
F
,
correspondingly.
1
2
d be
a(u,uFinally,

v path
in

(u,
H).2 Then,
is in
a
subgraph
ofAssume
Hconnected
v) contrary
.and let At
no
path
uThen,

exists
in
H
(u,
v)uv).

B(H
uand
v).
are
inEH2Y, but
2 path
1 , (u, the
2
H

v),
there
iscomponents.
also
no
B(H
).
there
isthat
vsay
show
that
nothe
path
exists
(
be such a
G,
define
G
least
evsuppose
as
G
with
edge
e As
removed.
Now
assume
1 same
1connected
1not
e
Clearly,
if
there
exists
a
path
u

v
in
H
does
not
contain
(u,
v).
does
We
may
contain
replace
(u,
the
v).
We
may
the
of
these
paths,
say
one
Q,
of
these
paths,
Q,
2
edges
b)same
P
such
(u,av).
Assume
the
contrary
Let
us(a,
show
that
no
path

v exists
[Then,
(u,
v).
AsinHwould
is
apath
subgraph
ofpath
H1 ,in
(u,v)
(
E
Yreplace
.
no
path
u

vconnected
exists
inHu
1
2).
2Hno
have
the
bgraph
of
H

(u,
v),
there
is
also
no
idge
in
H
,
i.e.,
(u,
v)

B(H
there
is
u

v
path.
If

,
then
be

),
which
is
not pos
2
1
1
1
2 if (a,
a path
en
ushow

vpaths
exists
inpath
H
Hv2X
is
aYsubgraph
of
Conversely,
u b)
with
the
edge
Q

(a,X.
with
By
replacing
the
path
all
Q

X.
edges
By
replacing
(a,
b)Hv).
with
all
paths
1If, uas
1 . be
, Let
there
exist
F
and
let
Ppath
be
such
ab)no
path.
PH

such
, in
then
would
asuch
u edges
v path
in with paths

(u,
Assume
the
contrary
us
that

exists
H1P
)
and
consequently

B(H
,in
H
and
H
have
the
same
connected
As
H

(u,
v)
is
a
subgraph
of

(u,
v),
there
is
also
no
2
sible.
Hence,
there
exists
some
edge
(
)
2

such
that
(
)
2

n
f(
)g.
1
2
2
1
avwe
path
, then
any
b)
P (u,
\ Y(a,
that
vX,
are
connected
in

(u,
v),
auedge
contradiction.

Thus,
v),
a
contradiction.
we
obtain
contained
asuch
path
uby
X,

inIfobtain
H
a path
v(a,
inwould
H
2
2edges
,dH
correspondingly.
At

(u,
v),P
which
is)Hnot
possible.
Hence,
there
exist
P path
such in Thus,
let
be
a1in
path.
PP

Psome
be
a such
ub)
0Y , then
0 v
2and
and
consequently
Thus,
(u,
v)
B(H

(u,
v).
Moreover,
H
and
H
have
the
same
connected
H

2
As
(
)
2

and
(
)
2

,
there
exist
paths

and

from

to

in
both
spanning
2
1
2
, b)
E(a,
X
can
be
path
a
contained
entirely
in F
(recall
)
consequently,
B(H
and,
) aAs
consequently,
B(H
).
B(Hexist
some
B(H
).there
(H
(u,Ewhich
v)
replaced
B(H
1 )v)}.
2by
1b)
2 ) b)
We
may
replace
the
exist
that
b)
\inY
X

/ Fbthere
and
(a,

/ F 1,edges
\v)
(u,
v),
is,{(u,
not
possible.
Hence,
(a,
b) paths
P such
Hand,
2 connected
d
v1Fare
H
but
thus
(u,

X
. \2Thus,
(u,
(a,
B(H
0v)
2 ) and consequently
forests

and

,
correspondingly.
At
least
one
of
these
paths,
say , does not contain
at
is
a
spanning
forest
of
H).

dges
(a,
b)
with
paths
Q
and
Q
from
a
to
b
in
both
spanning
forests
F
and
F
,
correspondingly.
At
,
there
exist
paths
that
(a,
b)

E
\
X
\
{(u,
v)}.
As
(a,
b)

/
F
and
(a,
b)

/
F
graph
v)
connected
E We
Y
. may
. For
Then,
uHand
vG,are
inasH
, but
1 , (u,
2
. the
(
).
replace
the
edge
( e)
with
the
path
By replacing all such
aof
graph
define
G
eboth
G
with
the
edge
removed.
Now
assume
these

contradiction.
Thus,
does
not
contain
(u,
v).
We
may
replace
least
one
of
paths,
say
Q,
Q
and
Q
from
a
to
b
in
spanning
forests
F
and
F
,
correspondingly.
At
u,
Assume
Hv).
is v)
a(u,
subgraph
ofcontrary
, (u,
v)
E
Yare
.contained
se
v)
the
B(H
).(
u
and
v
connected
in there
H
but
2that
1Then,
2H
2 ,obtain
at
(u,
isone
a with
bridge
in
H
i.e.,
(u,
v)By
B(H
Then,
is no
paths
v in the
edges
with
paths
in
,
we
a path
path
ureplace
2 ( ), a con1 ,)
1 ). contain
edge
(a,
b)
the
path
Q

X.
replacing
all
such
edges
(a,
b)
with
does
not
(u,
v).
We
may
least
of
these
paths,
say
Q,
would
a(u,
u v).

vAssume
path

the
contrary
tsists
in

(u,
v).
As
is
a is
subgraph
H
, )(u,
v)
E v),
Y there
.
inH(u,
H
1be
2 v).
2 in
1of
As
H
H(u,
v)
a X.
subgraph
(u,
is(
also
Hcontained
tradiction.
Thus,
(
2of
(
and,

) no

(1).
1
2the
1 (u,
1 2H
2with

v),
a contradiction.
Thus,
in
X,
we
obtain
aQvpath
u)

v
in
H
(a,
b)
with
path

By
replacing
allconsequently,
such
edges (a,
b)
paths
tth
some
edges
(a,
b)

P
such

Y ,uedge
then
P
would
be
a
u

path
in

(u,
v).
Assume
the
contrary
no
path
u

v
exists
in
H
1

(u,
v).
Moreover,
H
and
H
have
the
same
connected

v
in
H
2
1
2
B(H1
and,
B(H
B(H
v (u,
v), in
a contradiction. Thus,
contained
in)
X,X
we
a path
u
v ain
2)
21 ).
, and
there
exist
paths
a,
b)

/v)Fexist
e,(u,
some
edges
(a,
b)
h
athere
path.
If P
consequently,
Yobtain
, then
be
uH
path
mponents
thus
(u,
v)
X PPY would
.such
Thus,
(u,
v)
B(H
2 ) and consequently
v) B(H1 ) and,

consequently,
B(H
)

B(H
).
(u,
2
1
nd
F ,and
correspondingly.
At exist

/ )not
(a, b)
/Hence,
F , there
h)(H
is
possible.
there
existpaths
some edges (a, b) P such
1 B(H2 ).

We
may
replace
the
g(u,
forests
F
and
F
,
correspondingly.
paths
XFinally,
\v).{(u,
v)}.
As
(a,
b)

/
F
and
(a,

/ F , there
suppose that (u, v) B(H2b)
).At
Then,
u and exist
v are connected
in H2 , but

such
edges
(a,
b)
with
paths
not
contain
(u,
v).
We
may
replace
the
to
b
in
both
spanning
forests
F
and
F
,
correspondingly.
path u v exists in H2 (u, v). As H2 is a subgraph of HAt
1 , (u, v) E Y .
u,
contradiction.
Thus,
allthat
such
edges
(a,ucontain
b)with
paths
not
(u,
v).in We
the the contrary
eeplacing
paths,
say
Q, does
(u,replace
v). Assume
t v),
us ashow
no
path
v exists
H1 may

(u,
v),
a
contradiction.
Thus,
vd in
H
he
path
Q

X.
By
replacing
all
such
edges
(a,
b)
with
paths
2
let P be such a path. If P X Y , then P would be a u v path in
B(H1a).path u v in H2 Hence,
(u, v), there
a contradiction.
Thus, (a, b) P such
we
obtain
2)
exist some edges
2 (u, v), which is not possible.
nd,
consequently,
B(H
)

B(H
).
2
1
at (a, b) E \ X \ {(u, v)}. As (a, b)
/ F and (a, b)
/ F , there exist paths

and Q from a to b in both spanning forests F and F , correspondingly. At


ast one of these paths, say Q, does not contain (u, v). We may replace the
ge (a, b) with the path Q 19
X. By replacing all such
19 edges (a, b) with paths
ntained in X, we obtain a path u v in H2 (u, v), a contradiction. Thus,
, v) B(H1 ) and, consequently, B(H2 ) B(H1 ).
19
19

Olympiads in Informatics, 2016, Vol. 10, 195205


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.12

195

Reshaping Indonesian Students Training for IOI


M. M. Inggriani LIEM

Knowledge and Software Engineering Research Group

School of Electrical Engineering and Informatics, Institut Teknologi Bandung,


Jalan Ganesha 10, Bandung, Indonesia
e-mail: inge@informatika.org
Abstract. Indonesia has been participating at IOI (International Olympiad in Informatics) since
1995. This paper presents a result of qualitative study of Indonesian IOI participants. The supporting data are obtained from a questionnaire distributed to the IOI 2006 IOI 2015 participants, interviews, training database, journals, and reports from the national training program.
Main objective of the study is to investigate the suitability of our training program to IOI expectations. From 35 distributed questionnaires, we obtained 24 respondents. Without having
prior knowledge in Computer Science, solid mathematical foundation, and algorithmic problem
solving in formal education, the national training curriculum can only give the participants a
foundation for general problem solving which is not enough for IOI due to increase of creativity, complexity and difficulty of IOI tasks. That is why Indonesia achievement is stabilized in
bronze. Almost all of Indonesian IOI alumni are working or studying in the domain of informatics and still participating programming competitions after IOI. Most of all Indonesian IOI
participants are studying in top universities and some of them are working in the worldwide
prestigious IT companies.
Keywords: Indonesian IOI training program, qualitative research, IOI tasks.

1. Background
Amongst its objectives, IOI has two main objectives for the contestants: to give recognition to young people who are exceptionally talented in the fields of informatics, and to
foster international relationships among them.
The first participation of Indonesia at IOI was in 1995, by the initiative of young
lecturers of UI (Universitas Indonesia) who were studying in US. The training and selection of Indonesian participants was informal and voluntary, it then found its shape as
an organization in 2004, two years after the first Indonesian National Science Olympiad
(OSN). The support and sponsorship from the Indonesian Ministry of Education for
IOI and other International Olympiad is important. But the policy of the government
that aims to catch the potential candidates from all provinces of Indonesia becomes a
problem. Indonesia has more than 4 million high school students spread into more than
17,000 islands, from remote area to big cities. The quality of education in remote area is

196

M.M.I. Liem

less in big cities like Java due to infrastructure gap. Students in big cities are more advantageous in education. Also, getting medals in OSN is considered prestigious and give
good impact to the winners as well as to the school. Therefore, some schools in big cities
(Jakarta, the capital, and some others province capitals) recognize the importance of the
National Science Olympiad for their reputation, so that they are trying to get teachers
or trainers. Most students who are interested in computer games became interested in
programming, and by the support of their parents, they got private trainers for programming. This situation causes a broader gap.
The national selection process should keep a balance between potential candidates from remote areas and ready to compete candidates from the big cities. Up
until now, Indonesia cannot be classified as a top performing country in the IOI. Nonetheless, its performance is improving and become more stable in bronze medals (Yugo
et al., 2014). The summary of Indonesian team achievement in IOI from 2006 to 2015
is figured in Table 1.
This study was conducted with aim to reshape Indonesian national training program
so that improvement can be achieved by being stable in silver medals. We gathered
information from the past Indonesian IOI participants by giving a questionnaire. We
investigate what Indonesian IOI participants are doing after their experience in IOI. It is
important for the IOI community to know about their alumni after 910 years.

2. Related Works
Our work was inspired by the usage of qualitative research in computer science education. Formerly, the qualitative research has been applied to social research. Applying it
to science and technology is quite rare. Recently, this method became widely used for
informatics in education. M. Knobelsdorf (2008) presented a research using qualitative method in teaching of programming. A. Theodoraki and S. Xinogalos (2014) presented a qualitative study on students attitudes towards learning programming through
Table 1
Indonesian Participant Medal Achievement at IOI 2006 IOI 2015
Year

Gold

Silver

Bronze

2006
2007
2008
2009
2010
2011
2012
2013
2014
2015

0
0
1
0
0
0
0
0
0
0

1
0
0
2
2
0
1
2
0
2

0
4
3
1
1
2
2
2
4
1

Reshaping Indonesian Students Training for IOI

197

games. Hazzan et al. (2006) wrote about qualitative research in computer education. He
also wrote about teaching and learning qualitative research by conducting qualitative
research (Hazzan, 2014). In our case, this method is applied to the training and selection
program of Indonesian Olympiad participants.
A survey done and reported by Nedkov et al. (2012) concerning the selection, preparation and participation of IOI teams of Bulgaria, Croatia, Latvia, Poland, and Slovakia.
Those countries are the leading countries in the IOI. According to this survey, factors
contributed to the successful participation are traditions, strong emphasis on mathematics in national education, targeted extra-curricular activities, early start and gaining
experience by participating in competitions, systematics management and dedicated
people, motivation and rewards.

3. Objectives
This study is conducted in order to obtain findings related to:
a. Factors that help the participants to get medal in IOI.
b. Fitness of Indonesian training topics to IOI tasks.
c. The influence of IOI to the career of IOI participants.
The first questions are the most important since one of the main targets of IOI
participation is to win the competition that is getting medals, and the Indonesian education system has had bad results in mathematics in the PISA 2012 test. The Program
for International Student Assessment (PISA) is a worldwide study by the Organization
for Economic Cooperation and Development (OECD) in member and non-member nations of 15-year-old school pupils scholastic performance on mathematics, science,
and reading1. For winning a competition, a supporting curriculum is needed. The third
question is trying to track the career of the Indonesian IOI participant, since life is going on after IOI.

4. Design Experiment
This paper analyse the data obtained from Indonesian IOI participants from 2006 to
2015. During these last ten years, Indonesia has sent 40 participants (IOI alumni), 5 of
them have been participated twice. Therefore, we had 35 persons in the IOI during that
period. From the 35 Indonesian IOI alumni, we obtained 24 responses in two weeks by
contacting 3 alumni and asked them to contact the others. It makes over 70%. This is a
proof that there is a close relation between the coaches and the alumni, as well as between alumni. Three years after IOI, they are still active in programming competition, as
contestants in international competitions, Scientific Committee or Technical Committee
on Indonesian National Training program and competition.
1

http://www.oecd.org/pisa/keyfindings/pisa-2012-results.htm

198

M.M.I. Liem

The data are obtained from the following sources:


a. Indonesian National Training Program database, which are the participants, and
also the training program archives (journal, schedule, report).
b. Questionnaires, via Google questionnaires as well as via email.
c. Literature reviews for getting information about IOI tasks and solutions.

5. Findings and Discussions


Based on the questionnaire, we identify some findings, which are described in the following sections.

5.1. Effectiveness of the National Training Program


In the beginning, Indonesia did not have a systematics training program. Talented high
school students surround university faculty members were trained only a few weeks
before the IOI. Since 2002, the Ministry of Education of Indonesia has initiated the National Science Olympiad (OSN), where programming is one of the competition subjects
amongst 6 others (mathematics, physics, chemistry, economy, geology and astronomy).
In OSN, 80 to 100 high school students that have passed the successive selection at the
level of school, region, and then provinces are invited to come for a national competition
held in one of the city in Indonesia. Each year, the scientific committee must run two
concurrent programs: one for national selection (from school to OSN), while the other is
a program for trainings and selections for the next IOI.
One cycle of trainings and selections of IOI participants takes one year consists of
four phases (I, II, III, IV) training camps. Between two successive camps, candidates
must join on-line mentoring and challenge, and also participate in other informatics contests. Thirty candidates of OSN winners enter the phase I. After three weeks of training,
the scientific committee selects 16 top scorers to enter phase II. At the end of phase II,
eight participants are selected for phase III. Finally, only four participants undergo phase
IV becoming the official Indonesian IOI participants.
The organization of the training is getting better by having more IOI alumni and
their involvement. Most of the alumni are graduated in informatics and then they work
in worldwide prestigious information technology and software companies. Their experience both in competition, education as well as in their professional works helps to
improve the training and selection programs. Some of the IOI alumni participate voluntarily in the scientific committee as well as the technical committee for the two concurrent programs. They become mentors and problem setters in both programs. They also
set up an alumni organization (IA-TOKI) and have a close relationship with the scientific
committee, though they are scattered all over the world. They are developing a contest
management system which is used for on-line training program and some other regional/
local programming competitions nowadays. The contribution of IA-TOKI to the national training program is significant.

Reshaping Indonesian Students Training for IOI

199

Almost all of the respondents answer that the on-site training camps are very important and more effective than the on-line training:
1. They learn more from the mentors and from the peers during on-site training. Direct discussions are more effective than on-line learning.
2. They can focus more during the on-site training, compared to on-line training. The
students in an on-site training are relieved from school so that they can fully concentrate on the IOI preparation. On the other hand, students must prioritize their
school and daily tasks during on-line training.
3. They have a competitive environment during on-site training, especially in simulation sessions. Simulation trains the students how to manage their stresses, and
builds a competitive sense by the presence of other students.
4. Being together with peers during on-site training for weeks made the students know
each other better where they built a team spirit, and becomes friends.
5. They have a better internet connection.
There is one exception. One respondent stated that he prefer on-line training and
self-studying, and learning from worldwide existing on-line competitions, books and
on-line programming competition websites. It is then identified that his level is higher
compared to his peers, so that he became bored during the on-site training, though he attended and completed the whole on-site training programs. He was the one that achieved
a gold medal in IOI 2008.

5.2. Other Contributing Factors


Other factors that contribute the medal achievement are self-exercise, reading books,
on-line resources, and other competitions that made them regularly connect to the world
of competition.
When they are not in a training camp, 54% of the respondents were exercising themselves more than 10 hours per week, 17% only between 5 to 10 hours per week, 17% at
least 3 hours per week, and 13 % exercise irregularly.
They also try to solve past IOI tasks, but not so much. 46% solve more than 10 tasks,
17 % between 5 to 10 tasks, 25% less than 5 tasks, and 8% does not try to solve in past
IOI tasks, and 4% did not comment. Trying past IOI tasks seems not so interesting because they know that IOI tasks are very creative.
The following two figures (Fig. 1 and Fig. 2) illustrate those findings.
Other learning resources (Fig. 3) are websites and competition sites. 75% of the
respondents state that learning from the websites such as Topcoder, Usaco and SPOJ
are useful. 71% of them state that participation in competition is useful as preparation
for IOI.
Learning from textbooks seems to be least favourite option for this young generation. Only 33% of the respondents were learning from textbooks. Only two textbooks
are mentioned explicitly: Introduction to Algorithms (by Thomas H. Cormen, Charles E.
And Leiserson), and Competitive Programming (by Steven Halim).

200

M.M.I. Liem
12
10
8
6
4
2
0

30
20
10
More Between Less than
than 10 5 to 10 5 tasks
tasks
tasks

No

Figure 1. Hours Spent by Indonesian IOI Participant for self-

12
10
8
6
4
2
0

12
10
8
6
4
2
0

Figure 2. Number of IOI Tasks exercised by Indonesian IO

Fig. 1. Hours Spent by Indonesian


IOI Participant for self-preparation.
preparation
Participant
30

Other learning resources are websites and competition sites. 75% of the respondents state that learning
20
from
30 the websites such as Topcoder, Usaco and SPOJ are useful. 71% of them state that participation in
competition is useful as preparation
10 for IOI.
20
More Between Less than
than 10 5 to 10 105 tasks
tasks
tasks

More Between Less than


than 10 5 to 10 5 tasks
tasks
tasks

Blank

30

No

25

Blank

0
1

0
20
Figure 1. Hours Spent by Indonesian
IOI Participant
for self- Figure 2. Number of IOI Tasks exercised by Indonesian IOI
No
Blank
2
3
4
5
preparation 1
Participant
15

Other learning
are websites
competition
sites.
of the respondents
state that learning
Fig.resources
2. Number
of IOIand
Tasks
exercised
by75%
Indonesian
IOI Participant.
10
the websites
such Figure
as Topcoder,
Usaco
SPOJ are
useful.by71%
of them IOI
state that participation in
Figure 1. Hours Spent by Indonesian IOIfrom
Participant
for self2. Number
of and
IOI Tasks
exercised
Indonesian
preparation for IOI.
preparation competition is useful asParticipant
5

Other learning resources are websites and competition


sites. 75% of the 0respondents state that learning
30
Formal on-site Online pre- Learning from Learning from Participating in
from the websites such as Topcoder, Usaco and SPOJ are useful. 71% of them
state that participation in
25
national
national
websites
the books
other
competition is useful as preparation for IOI.
Training
training
competitions
20

30

15

25

10

20

15

Figure 4. Various Ways of Learning for IOI preparation

Learning from textbooks seems to be least favourite option for this young generation. Only 33% of the
respondents were learning from textbooks. Only two textbooks are mentioned explicitly: Introduction to
Algorithms (by Thomas H. Cormen, Charles E. And Leiserson), and Competitive Programming (by Steven
Halim).

Formal on-site Online pre- Learning from Learning from Participating in


Besides the national training program, all of the respondents participate regularly in the worldwide
national
national
websites
the books
other
competitions,
not only in the period of national
training, but also few years after participating IOI.
Training
training
competitions

10

Competition becomes their hobbies, and they are getting more and more experience in that domain so that

Figure 4. Various Ways of Learning for IOI preparation

they3.become
national
scientific for
members
and trainers in a national training program or task contributors
Fig.
Variousthe
Ways
of Learning
IOI preparation.

Learning from textbooksinseems


to be least
favourite option
for this young
generation.
Onlyfavourite
33% of thecompetition websites are TopCoder,
prestigious
international
programming
competitions.
Their
Online
pre- Learning
from from
Learning
from Participating
in
respondents
were learning
textbooks.
two
textbooks
are mentioned
explicitly:
to and local competitions.
Usaco, Only
APIO,
COCI,
CEOI, Joint,
BEOI, Google
CodeIntroduction
Jam, ACM ICPC,
national
websitesCodeforces,
the books
other
Algorithms (by Thomas H. Cormen, Charles E. And Leiserson), and Competitive Programming (by Steven
training
competitions
Halim).
Besides
the national training program, all of the respondents participate regularly
Figure 4. Various Ways of Learning for IOI preparation
Besides the national
training program,
all of in
thethe
respondents
regularly
in the worldwide
in the worldwide
competitions,
not only
period participate
of national
training,
but also few
2016
Paper
Page
5 of 10training, but also few years after participating IOI.
competitions,
notoption
onlyIOIinfor
the
period
national
Learning from textbooksyears
seems to
be
least
favourite
this
youngofgeneration.
Only 33% of
the hobbies, and they are getting
after
participating
IOI.
Competition
becomes
their
Competition
their hobbies,
and they are
getting more
and moretoexperience in that domain so that
respondents were learning from textbooks.
Onlybecomes
two textbooks
are mentioned
explicitly:
Introduction
more and
more
experience
in that
domain
so that
they
become
theor national
scientific
they
become
theLeiserson),
national scientific
members
and
trainers
in a (by
national
training
program
task contributors
Algorithms (by Thomas H. Cormen, Charles
E. And
and Competitive
Programming
Steven
in
prestigious
international
programming
competitions.
Their
favourite
competition
websites
are
TopCoder,
members
and
trainers
in
a
national
training
program
or
task
contributors
in
prestigious
Halim).
Codeforces, Usaco, APIO, COCI, CEOI, Joint, BEOI, Google Code Jam, ACM ICPC, and local competitions.
Formal on-site
national
Training

international programming competitions. Their favourite competition websites are Top-

Besides the national training program, all of the respondents participate regularly in the worldwide
Codeforces,
CEOI,
BEOI,
competitions, not only Coder,
in the period
of nationalUsaco,
training,APIO,
but alsoCOCI,
few years
after Joint,
participating
IOI. Google Code Jam, ACM
Competition becomes their
hobbies,
and
they
are
getting
more
and
more
experience
in
that
domain
so
that
ICPC, and
local
competitions.
IOI 2016
Paper
Page 5 of 10
they become the national scientific
and trainers
in a nationalthat
training
or taskingredients
contributors are important for being
One members
of the alumni
mentioned
theprogram
following
n prestigious international programming competitions. Their favourite competition websites are TopCoder,
successful in IOI: grit/ perseverance, time management and prioritization, attention to
Codeforces, Usaco, APIO, COCI, CEOI, Joint, BEOI, Google Code Jam, ACM ICPC, and local competitions.

detail, creative thinking, the ability to recognize pattern on problems, experience with
common tricks and avoiding common pitfalls, experience with a breadth of topics.

OI 2016 Paper Page 5 of 10

Reshaping Indonesian Students Training for IOI

201

5.3. Fitness of Training Topics to IOI Tasks


A curriculum of the training program is progressing continuously since 2006, in three
periods. During the first period (20062010), most of the trainers are the university
faculty members. IOI alumni participation in the second period (20112013) and the
third period (20142015) brings new colour to the program. The ambiance of programming competition becomes stronger. More than that, the creative problem solving
exercises is introduced in addition to the classical training subject. The scientific committee is working together with IOI alumni closely for the training program subjects
and tasks.
In the beginning, the phase I of training is dedicated to assure the basic foundation
of CS (programming, advanced topics, while phase III is dedicated to simulation and
the selection of four IOI participants. Phase IV is the final preparation before going to
the IOI.
From one year to another, IOI tasks become more creative, unpredictable and difficult (Halim, 2013). All countries training program must anticipate these changes and
shifted accordingly. As a consequence, Indonesia decides to shift the basic skill gradually from on-site to on-line training by providing on-line course material in Indonesian
contest management systems. The students should develop their self-learning capability. This solution works well for students living in big cities with good infrastructure
as well as good internet reliability and availability, and good teachers are available. In
addition to the shifting of basic skills in CS, exercise and simulations are designed to
be harder and more challenging. Table 2 illustrates the different strategies of the three
periods.
As illustrated above in Table 1, the achievement of Indonesian team is stabilized in
Bronze medals. The year 2008 is a special year with one gold medal obtained by a prodigious student. The year 2011 is also exceptional with only one bronze obtained because
of two reasons: a transition of the training method and too much given exercises that are
not in the IOI style.
Table 2
Overview of Training Program Curriculum from 2006 to 2015
IOI year

Training Phase I

Training Phase II

Training Phase III

Training Phase IV

20062010 Basic programming


Basic Exercises
Simple simulation

CS topics, strategic problem solving


Simulation

Advance Topics and


Simulation

Final IOI preparation

20112013 Basic programming


CS Topics, strategic
problem solving,
simulation

Advanced Topics and advanced problem


Simulation

Advanced Topics and


simulation

Final IOI preparation

20142015 CS Topics and


Advanced Topics &
strategic problem
solving, simulation

Special advanced topics


More Simulation

More Simulation,
Final IOI preparation
more ad-hocs problem

202

M.M.I. Liem

This part is a deeper look to the subjects covered during the training programs, contains the analysis among the topics covered in the Indonesian training and IOI tasks.
As mentioned above, the Indonesian high school curriculum does not cover computer science as a compulsory subject, compared to other countries where the computer
science concepts has been introduced since the earlier age, from 1014 years (Dagien
and Futschek, 2010, Nedkov, 2012). Three phases of training, each lasts for 3 weeks
can cover all the required topics suggested by IOI curriculum. However, topics such as
strategic problem solving and thinking take time to be mastered. Many exercises are also
needed in order to construct the pattern of problems as well as the pattern of solutions.
These patterns are important for solving the creative IOI task.
The national training program topics covered the last version of the IOI syllabus,
obtained from the website2. National Training topics exclude basic computer science
and mathematics listed in the IOI syllabus and respondents made remarks regarding the
importance of those topics (Fig. 4) for IOI.
In a questionnaire after IOI 2015, a list of topics is given. The country leaders were
asked to rate the importance of them. In this study, we also try to explore the opinions
of respondents regarding these topics, and we got the following results: Maximum flow,
flow/cut duality theorem (67%); Strongly connected components, bridges and articulation points (54%); Heavy-light decomposition and separator structures for static trees
(25%); Data structures for dynamically changing trees and their use in graph algorithms
(54%); Topics in number theory (33 %); String algorithms (54%).
Additionally, IOI tasks and solutions from IOI 2006 to IOI 2015 were analysed.
The respondents are asked to mention the most interesting, the most difficult, and the
most memorable IOI tasks. From these, we obtained 74 tasks. These tasks are then cross
checked to the topics listed.

This part is a deeper look to the subjects covered during the training programs, contains the analysis among
the topics covered in the Indonesian training and IOI tasks.
25
20
15
10
5
0

Figure
Importanceof
of Training
Training Topics.
Topics.
Fig. 4.5.Importance

As mentioned above, the Indonesian high school curriculum does not cover computer science as a
compulsory subject, compared to other countries where the computer science concepts has been introduced
since the
earlier age, from 10-14 years (Dagiene & Futschek, 2010, Nedkov, 2012). Three phases of training,
2
http://ksp.sk/~misof/ioi-syllabus/
each lasts for 3 weeks can cover all the required topics suggested by IOI curriculum. However, topics such as
strategic problem solving and thinking take time to be mastered. Many exercises are also needed in order to
construct the pattern of problems as well as the pattern of solutions. These patterns are important for
solving the creative IOI task.
The national training program topics covered the last version of the IOI syllabus, obtained from the website2.

Reshaping Indonesian Students Training for IOI

203

The summary of this cross check and analysis illustrate the applicability of our training topics for solving IOI tasks:
The importance of the topics ranked in figure Fig. 4 has high correlations with the
technics needs to solve the IOI tasks.
Graph, DP, Greedy, sort and search are very important, but they alone are not
enough, since the variation and specific condition of the graph can improve the
algorithm.
Algorithm complexity is important for measuring the performance of algorithm in
order to solve more difficult subtasks.

5.4. Influence of IOI to Participants Careers


IOI influences strongly to the Indonesian participants careers. By winning medals in IOI,

theyofcan
enter
easily
to top
Indonesian
in Informatics,
even
the toptopics for solving
The summary
this
cross
check
and
analysis universities
illustrate the
applicability
of entering
our training
universities
in
the
world.
All
of
the
participants
are
studying
in
the
fields
of
informatics
tasks:
shown by the
graphics
5. 5 has high correlations with the technics needs to
- Theasimportance
offollowing
the topics
rankedininFig.
Figure
Most of the Indonesian alumni of IOI 20062008 have graduated from bachelor
solve the IOI tasks.
degree and now working or studying PhD level. Some of them are founders or CTO
- Graph,
DP,
Greedy,
sort andcompanies
search are
important,
but they
alone
are not and
enough, since the
at top
start-up
Indonesian
in very
the domain
of software,
offers
internship
variation
and
specific
condition
of
the
graph
can
improve
the
algorithm.
employees their juniors. Some medallists are working for prestigious companies in the
US and complexity
UK as software
developers.for
The
younger alumni
are now studying
in bachelor
- Algorithm
is important
measuring
the performance
of algorithm
in order to solve
or
master
program
in
informatics.
Only
2
of
24
participants
are
studying
in
other
domore difficult subtasks.

mains: one is studying in medical faculty, and another is studying in the first common
year (he is intended studying in informatics). This finding shows that IOI is a starting
5.4 Influence
oftheir
IOI study
to Participants
point for
and then theirCareers
career in informatics. The IOI gave them motivation
for strongly
studying and
working
abroad.participants
IOI medal is acareers.
free ticket
enter topmedals
universities
andthey can enter ea
IOI influences
to the
Indonesian
Bytowinning
in IOI,
obtaining
scholarships.
to top Indonesian universities in Informatics, even entering the top universities in the world. All of

participants are studying in the fields of informatics as shown by the following graphics in Figure 6.
15
10
5
0
Studying abroad

Studying
Bachelor in
Indonesia

Master & PhD

Figure
6. Indonesian IOI Alumni Tracking.
Fig. 5. Indonesian IOI Alumni Tracking.

Most of the Indonesian alumni of IOI 2006-2008 have graduated from bachelor degree and now workin
studying PhD level. Some of them are founders or CTO at top start-up Indonesian companies in the dom
of software, offers internship and employees their juniors. Some medallists are working for prestig
companies in the US and UK as software developers. The younger alumni are now studying in bachelo

204

M.M.I. Liem

6. Conclusions
This paper presents a study of Indonesian IOI participants from 2006 to 2015, where
the data come from questionnaire distributed to them, interviews, national training database, journal of national training program, and from training reports. The study aimed
to identify the appropriateness of our national training program to IOI participation,
since we have only 1 gold in 2008, and in the last 4 years our achievement is stabilized
in bronze. With the limitation of respondents, the findings from the pass IOI in this
study will be used to reshape our strategy in the coming year, for moving at least to
silver. We must also consider that IOI task is getting more unpredictable, difficult, and
creative (Halim, 2013).
Without having computer science, solid mathematical foundation, and algorithmic
problem solving in their formal education, three phases of training each last for three
weeks on-site plus three weeks extra for final preparation are not enough for preparing IOI gold medallist, unless we can find a prodigious student. Bebras challenge3 is a
potential way to bridge the gap in computational thinking since an early age. Indonesia
will join Bebras (Dagien & Stupurien, 2014) during the coming year. Indonesia will
remain participate actively in IOI since the outcome of the participation and achievement in IOI also improves the spirit of competition amongst Indonesian senior high
school students which in turn also means improvement in quality of high school education in Indonesia.
Last but not least, this paper highlights the difference of Computer Science, mathematics education in elementary, middle and high school of IOI countries. Formal education in Computer Science, mathematics and problem solving from an earlier age
contributes to the success of the participants in IOI. One year, or more precisely four
training camps three weeks each, is not enough to well prepare IOI participants unless
we are lucky to find an extraordinary student.

Acknowledgment
I would like to thanks Adi Mulyanto who help me connecting to the Indonesian IOI
alumni for getting the data, and also to the 24 respondents for their quick responses to
the questionnaires. I would also like to show my special gratitude to Prof. Valentina
Dagien, who introduced to me about qualitative research, inspired and encouraged me
for writing this paper.

http://bebras.org/

Reshaping Indonesian Students Training for IOI

205

References
Dagien, V., Futcheck, G. (2010). Introducing informatics concepts through a contest. Presented in: IFIP Workshop New Developments in ICT and Education held at Universit de Picardie Jules Verne, Amiens, France
2830 June.
Dagien, V., Stupurien, G. (2014). Informatics education based on solving attractive tasks through a contest.
Commentarii informaticae didacticae, 7, 97115.
Halim, S. (2013). Expecting the Unexpected. Olympiad in Informatics, 7, 3641.
Hazzan, O., Dubinsky, Y. et al. (2006). Qualitative research in computer science education. In: SIGCSE 06
Proceedings of the 37th SIGCSE Technical Symposium on Computer Science Education. 408412.
Hazzan, O., Nutov, L. (2014). Teaching and Learning Qualitative Research ~ Conducting Qualitative Research,
The Qualitative Report 2014, vol 19, Teaching & Learning Article 1, 129.
Knobelsdorf, M. (2008). A typology of CS preconditions for learning. In: Koli 08 Proceedings of the 8th International Conference on Computing Education Research. 6271.
Nedkov, P. (2012). Young Talent in informatics: preliminary findings of an IOI survey launched by AICA in
cooperation with IT STAR. Olympiad in Informatics, 6, 192198.
Theodoraki, A., Xinogalos, S. (2014). Studying students attitudes on using examples of game source code for
learning programming. Informatics in Education, 13(2), 265277.

M. M. I. Liem is a member of Knowledge and Software Engineering Research Group, School of Electrical and Engineering, Institut
Teknologi Bandung (ITB). She has been teaching programming in ITB
since 1977 and obtained her doctoral degree in University of Joseph
Fourier Grenoble France in 1989, with teaching programming as major
topics of her dissertation. From 2004, she is involved as a team member in national recruitment, training and IOI preparation for Indonesian
team.

207222
Olympiads in Informatics, 2016, Vol. 10,
Informatics,
2016, Vol. 10,
Olympiads
2016 Vilnius
IOI,inVilnius
University
University
2016
Vilnius University
10.15388/ioi.2016.13
DOI:
DOI:

207
1
1

oii-web
oii-web:: an
an Interactive
Interactive Online
Online Programming
Programming

*
Contest
Contest Training
Training System
System*

1
1
1,2,3
2,3
William
Marco
WilliamDi
DiLUIGI
LUIGI1, ,Gabriele
Gabriele FARINA
FARINA1,, Luigi
Luigi LAURA
LAURA1,2,3,, Umberto
Umberto NANNI
NANNI2,3,, Marco
2,3
2,3
1
2,3
1
Umberto NANNI
, Marco TEMPERINI
, Luca VERSARI
TEMPERINI
LucaVERSARI
VERSARI1
TEMPERINI2,3, ,Luca

Italian
Association for Informatics and Automatic Calculus (AICA)
1
Italian Association for Informatics and Automatic Calculus (AICA)
Department
2
DepartmentofofComputer,
Computer,Control,
Control,and
and Management
Management Engineering
Engineering
Sapienza
University
of
Roma,
Italy
Sapienza University of Roma, Italy
3
Research
3
ResearchCenter
Centerfor
forDistance
DistanceEducation
Education and
and
Technology
Enhanced
Learning
Technology Enhanced Learning(DETEL)
(DETEL) Unitelma
Unitelma University
University
{gabr.farina,williamdiluigi,veluca93}@gmail.com
e-mail:
{fgabrfarina,williamdiluigi,veluca93}g@gmail.com
e-mail: {fgabrfarina,williamdiluigi,veluca93}g@gmail.com
{laura,nanni,marte}@dis.uniroma1.it
{laura,nanni,marte}@dis.uniroma1.it
1

our
experience,
related
to to
the
online
training
for for
the the
Italian
and
Abstract.
InInthis
this
paper
we
report
our
experience,
related
online
training
for
the Italian
Italian
Abstract.In
thispaper
paperwe
wereport
report
our
experience,
related
to the
the
online
training

International
Olympiads
in Informatics.
We developed
an interactive
online
system,
based
on the
and
Olympiads
in
We
an
online
system,
based
on
andInternational
International
Olympiads
inInformatics.
Informatics.
We developed
developed
an interactive
interactive
online
system,
based
on
Contest
management
System
(CMS),
the grading
system
usedused
in several
majormajor
programming
conthe
management
System
(CMS),
the
system
in
programming
theContest
Contest
management
System
(CMS),
the grading
grading
system
used
in several
several
major
programming
tests
including
the International
Olympiads
in Informatics
(IOI), and
used
it in
three
distinct
contests
including
the
Olympiads
in
(IOI),
and
used
it in
in
three context:
distinct
contests
including
theInternational
International
Olympiads
in Informatics
Informatics
(IOI),
and
used
it
three
distinct
training
students
for
the
Italian
Olympiads
in
Informatics
(OII),
training
teachers
in
order
to
able
context:
training
students
for
the
Italian
Olympiads
in
Informatics
(OII),
training
teachers
in
order
context: training students for the Italian Olympiads in Informatics (OII), training teachers inbeorder
students
forstudents
the OII, for
and
training
the
team
the IOI.
The
freely availtotoassist
be
totoassist
OII,
training
the
Italian
team
for
the
Theis system,
system,
that
beable
able
assist
students
forthe
the
OII, and
andItalian
training
thefor
Italian
team
forsystem,
the IOI.
IOI.that
The
that
able,
proved
to be a proved
game
changer
the whole
Italian
Olympiads
in informatics
ecosystem:
in one
is
available,
toto be
game
changer
for
whole
Olympiads
in informatics
informatics
isfreely
freely
available,
proved
be aafor
game
changer
for the
the
whole Italian
Italian
Olympiads
in
year,
we almost
doubled
to OII,
13k to 21k
ecosystem:
ininone
year,
we
almost
the
participation
to
OII,
13k
to students.
21k secondary
secondary
ecosystem:
one
year,the
weparticipation
almost doubled
doubled
thefrom
participation
to secondary
OII, from
from school
13k to
21k
Being
developed in CMS (http://cms-dev.github.io/), the system is highly available to
school
students.
school
students.
extensions
supporting,
instance,
the production of feedback on
submitted
Being
CMS
(http://cms-dev.github.io/),
the
system
highly available
available
to
Beingdeveloped
developedininfor
CMS
(http://cms-dev.github.io/),
theproblems
system is
issolutions
highly
to
by
trainees.
It
is
also
freely
available,
with
the
idea
of
allowing
for
support
to
alternative
necessiextensions
supporting,
for
instance,
the
production
feedback
on
problems
solutions
submitted
extensions supporting, for instance, the production of feedback on problems solutions submitted
ties
and developments.
by
ItItisisalso
necessibytrainees.
trainees.
alsofreely
freelyavailable,
available, with
with the
the idea
idea of
of allowing
allowing for support to alternative necessities
and
developments.
ties
and
developments.
Keywords: programming contest, Olympiads in informatics, programming training, problem recommendation
model.
Keywords:
contest,
recKeywords:programming
programming
contest,Olympiads
Olympiads in
in informatics,
informatics, programming training, problem recommendation
ommendationmodel.
model.

1. Introduction
The International Olympiads in Informatics (IOI) are an annual programming competition for secondary school students patronised by UNESCO. First IOI has been in Bulpreliminaryversion
versionofofthis
thispaper
paperappeared
appeared as
as W.
W. Di
Di Luigi,
Luigi, G.
G. Farina,
Farina, L. Laura, U. Nanni, M. Temperini,
**AApreliminary
Temperini,
andL.L.Versari.
Versari.Three
ThreeUses
Uses of
of the
the Online
Online Social
Social Programming
Programming Training
Training System: On Nature and Purpose
and
Purpose
SpreadingAlgorithmic
AlgorithmicProblem
ProblemSolving.
Solving. Proceedings
Proceedings of
of the
the 8th
8th International Workshop on Social
ofofSpreading
Social and
and
PersonalComputing
Computingfor
forWeb-Supported
Web-Supported Learning
Learning Communities,
Communities, (SPEL
(SPEL 2015), State of the art and Future
Personal
Future
DirectionsininSmart
SmartLearning,
Learning,369379,
369379,2016.
2016.
Directions

208

W. Di Luigi et al.

garia in 1989. The 2015 IOI, held in Almaty, Kazakhstan, saw participation by 83 countries and 322 contestants (each country can have up to four contestants). Participants are
usually the winners of national competitions.
Here we first introduce oii-web, an interactive online training platform, based on
the Contest Management System (CMS, http://cms-dev.github.io/ (Maggiolo
and Mascellani, 2012; Maggiolo etal., 2014)), that is the grading system used in several
programming competitions, including IOI. We built, around oii-web, three distinct, in
both target audience and functionalities, web based platforms: one dedicated to students
preparing for the Italian Olympiads in Informatics (OII), one for the teachers, with a
complete course on programming and several resources available, and the third to support the selection and the training of the Italian team for the IOI. We believe that our
online training system fills a gap, since there are several open source grading systems
and several online training platform, but to the best of our knowledge there is no open
source solution if one wants to host his own training platform.
We report on our experience with the three platforms, designed around the common
core, oii-web, that allows to navigate through problems, propose solutions, and get
feedback about it.
The overall system is already apt to be fruitfully used, with educational aims, as a
tool for competitive programming. Yet we are pursuing its enrichment with aspects of
personalization to trainees characteristics and needs, aiming to better help them enhance
their abilities to deal with contest problems: this would be novel, to our knowledge. So,
in the last part of the paper we discuss the requirements of such extension showing an
initial modeling schema for problems, solutions, and ultimately trainees.

2. Related Work
Here we deal with various topics connected to programming competitions and, more
generally, computer programming learning for secondary school students: a web training
platform, the organization of national Olympiads in informatics, and our experience in
broadening the participation to it.
On these topics a crucial information source is the Olympiads in Informatics journal,
founded in 2007, providing an international forum for presenting research and developments in the specific scope of teaching and learning informatics through Olympiads
and other competitions. Books such as (Skiena and Revilla, 2003) and (Halim and
Halim, 2013) provide also essential material about algorithms, data structures, and heuristics needed in programming contests.
The importance and the effectiveness of programming contests in learning programming and, more generally, computer science has been observed and emphasized greatly
in the literature: we mention the works of Dagien (Dagien, 2010) and Garcia-Mateos
and Fernandez-Aleman (Garcia-Mateos and Fernandez-Aleman, 2009).
Various kinds of automated support to programming education are met in research since
decades. The widest area of investigation seems to be related to introductory programming
courses, where students learn to write programs, according to a programming language

oii-web: an Interactive Online Programming Contest Training System

209

syntax and semantics, and to solve problems. In this way students are trained on both basic algorithms and their coding. Programming errors are spotted basically in two phases:
syntactic and static semantics errors are pointed out by the compiler, while logic/dynamic
semantics erros are spotted by testing. So, program assessment is usually based on:
Static Analysis, that gathers information about the program and produce feedback without execution. In this family fall approaches based on compiler error
detection and explanation (Hristova etal., 2003; Watson etal., 2012), structured
similarity between marked and unmarked programs (Naud etal., 2010), and also
nonstructural analysis, keyword search and plagiarism detection (Khirulnizam
and Md, 2007).
Dynamic Analysis, that tests the program on accurately chosen input datasets and
compares actual and expected output. One important application of this program
analyses is in competitive learning tools, used to manage programming contests,
such as (Leal and Silva, 2003).
In Wang etal. (2011) combine the two approaches: first the program undergoes static
analysis, for compilation errors and to check similarity with model programs. Then
a dynamic testing is performed, and possibly the program adds in a set of model programs.
Grading systems such as CMS are mainly based on dynamic testing, and are many:
amongst them are those used in ACM International Collegiate Programming Contest
(ICPC), i.e. the proprietary Kattis1, and the open source PC2, available at http://pc2.
ecs.csus.edu/. Other open source grading systems are Open Judge System2 and
DOMjudge3.
If we focus on online training platforms, amongst several high quality ones are UVa
Online Judge4 and the more recent Sphere Online Judge5 (SPOJ). Besides these training platform, there are several well-known programming contests platforms, including
Codeforces, USACO, COCI, TopCoder, Codechef, and Hackerearth, that run contests
with different periodicity. There are also events based on programming contests, like
the Google Code Jam and the Facebook Hacker Cup. A detailed survey of programming
contests is in (Combfis and Wautelet, 2014).

3. Italian Olympiads in Informatics


The International Olympiads in Informatics started in Bulgaria in 1989, patronised by
Unesco. They are considered one of the most important programming competition in the
world. Each country can have four contestants, and the competition is divided in two
competition days. On each day contestants will be given three tasks to complete in five
hours. Each task is worth 100 points and, since IOI 2010, it is divided into subtasks, each
1

https://kth.kattis.com/
https://github.com/NikolayIT/OpenJudgeSystem
3
http://www.domjudge.org/
4
https://uva.onlinejudge.org/
5
http://www.spoj.com/
2

210

W. Di Luigi et al.

worth a portion of the total points. There are time and memory limits for each subtask,
and points are awarded only when all the tests in subtask yield correct results within the
limits. There are also interactive tasks, like games, in which the contestant code alternates moves against an adversary.
In Fig. 1 we can see a graphical representation of a task, taken from OII 2014 final.
The task, taglialegna (lumberjack), can be summarized in the following way: there
is a line of trees, with one meter of space between each of them. Each tree has a known
height, in meters, and you can cut it aiming it toward its right or left. When an meter
tree falls, like in a domino game it forces the falling of its 1 close trees, and this in
turn can force other tree to fall. You can decide which tree to cut, and for each of them
you can choose in which direction it will fall. What is the minimum number of trees to cut
in order to remove all the trees in the line? For this task, the subtasks were designed to
OII 2014 of
Finale
nazionale
distinguish algorithms
different
computational costs: if we denote with the number
of trees in the Fisciano,
line, all19the
points
were
() solution,
settembre 2014 awarded to a (definitely not trivial)
taglialegna
IT
achieved by only one contestant, and decreasing points were assigned, respectively, to
( log
(2),della
and chiamata
(3) solutions.
),
Al termine
a Pianifica non tutti gli alberi sono caduti.
Italyparticipated
in chiamata
IOI for the
first time
2001
started a national
Viene fatta una
ad Abbatti
con in
un 2000,
indice oand
unasince
direzione
nonitvalidi.
Viene
fatta una by
chiamata
ad effort
Abbatti
un albero gi
caduto, direttamente
ad
competition,
promoted
a joint
ofcon
thelindice
ItaliandiMinistry
of Education,
University
opera(MIUR)
degli operai
o indirettamente
a seguito dellurto
con un altro albero.
and Research
and
the Italian Association
for Informatics
and Automatic Calculus (AICA, a non-profit organization). The Italian Olympiads in Informatics (OII) are
Esempiinto
di three
input/output
divided
phases:
input.txt
7
2 3 2 1 4 2 1
6
3 1 4 1 2 1

output.txt
4 0
5 1
0 1

4
3
2
1

Spiegazione

Nel primo caso desempio possibile abbattere tutti gli alberi segando il quinto albero (alto 4 deca2 3 2 1 4 2 1
metri) facendolo cadere a sinistra, e il sesto albero (alto 2 decametri) facendolo cadere a destra. Il primo
albero tagliato innesca un effetto domino che abbatte tutti gli alberi alla sua sinistra, mentre il secondo
a
abbatte lultimo albero nella caduta.
4

2 3 2 1 4 2 1

4
3

2 3 2 1 4 2 1

2 3 2 1 4 2 1

2
1

2 3 2 1 4 2 1

2 3 2 1 4 2 1

2 3 2 1 4 2 1

b
Fig. 1. The graphical representation of the task taglialegna (lumberjack), from OII 2014

Nel secondo
caso
desempio
tagliando
il primosolution
albero in
modo
final: an
input
instance (a)
and a possible
that
usesche
twocada
cuts verso
(b). destra vengono abbattuti
anche tutti gli alberi rimanenti.
4

oii-web: an Interactive Online Programming Contest Training System

211

1. First Selection (Schools, November): in this phase, in their own schools, approximately 20k students compete to solve, on paper, a test that involves math,
logic, and programming abilities; in particular, there are some fragments of code
(C/C++ or Pascal), and the students are asked to understand the behavior of the
fragments.
2. Second Selection (Regions, April): in this phase there are approximately 40
venues, where approximately 1200 students, selected from the previous phase,
compete by solving three programming tasks on the computer. In this phase
points are awarded for solving the tasks, independently from the complexity of
the solution.
3. Third Selection (National Final, September): approximately 100 students are
asked to solve efficiently three programming tasks on the computer. They compete
for 5 gold, 10 silver and 20 bronze medals.
From the above description it should be clear how the required programming abilities are varying through the different steps: we first ask students to be able to read code,
then to write code, and finally efficiently write code. A more detailed picture of the OII
organization is described in (Casadei etal., 2007).
The selection process does not end with the national final: the gold and silver medal
winners, together with at most five bronze medal winners, selected by (young) age, form
the group of IOI-candidates, and four of them will represent Italy in the next IOI (usually held in July or August). Thus, there is almost one year to train and select them, and
this process is mainly done in four stages held nearby Volterra6. In each of the stages
there are theoretical lessons, ranging from traditional algorithms and data structures to
competitive programming tips and tricks, as well as programming contests. Besides the
stages, there is a continuous on-line support for selfimprovement: the IOI-candidates are
assisted by tutors (former IOI contestants) for assistance and guidance, and several training contest are organized, some of which focused on specific topics.

4. The Online Training System: oii-web


Our online training platform, oii-web, is based on the Contest Management System
(CMS) (Maggiolo and Mascellani, 2012; Maggiolo et al., 2014), the grading system
used in several programming competitions, including IOI. CMS was designed and coded
almost exclusively by three developers involved in the Italian Olympiads in Informatics:
Italy hosted IOI 2012 and therefore, since 2010, it started the development of CMS, that
was used/tested in the OII finals 2011 and, few month later, was the grading system of
IOI 2012. CMS version 1.0 was released in March 2013, and since then has been used
in both IOI 2013 and 2014, together with several other programming competitions in the
world (Maggiolo etal., 2014).
6

The small city of Volterra in Tuscany is nowadays world-wide popular due to the fact that in the novels and
movies of the Twilight vampire saga it is the origin place of Volturi, the largest and most powerful coven of
vampires.

212

W. Di Luigi et al.

We began the development of oii-web during the preparation of the IOI-candidates


for IOI 2012: why did we need an online training platform? The short answer is: in a programming competition there are very few (usually from 3 to 7) problems, to be solved
in a short frame of time; in order to train the IOI-candidates we needed a system that
allowed us to give them more problems they can solve whenever they want, so the first
version of oii-web was simply an instance of CMS with one competition running, with
several problems and unlimited time. For training the IOI-candidates and, later, the two7
Italian teams competing in IOI 2012.
Later, we started using it consistently, and our feature list was growing almost daily,
both for the front-end and for the back-end of the system:
1. It would be nice to provide some information about each problem, so the student
can choose it without reading the whole description.
2. It would be nice to have a way to exchange messages, so students and tutors can
chat about the problems.
3. It would be nice to be have a way to show/hide problems, so we can use some of
them in contests to rank the students.
4. It would be nice to have stats about each problem, and who was able to solve it (in
a grading system there are these stats but not visible to contestants).
Thus, we decide to include all these above mentioned features, together with others,
and build an online grading system, oii-web. We integrated the open source Discourse8
to provide forum functionalities. The source code of the system is freely available9 in
github and it is released under the GNU Affero General Public License10. Furthermore,
it is also available11 as a dockerized app for docker12, an open platform to build, ship,
and run distributed applications.

5. The Three Platforms


In this section we briefly describes the three platforms, based on oii-web, we developed, and their differences.
OII-training is the platform devoted to the students that are interested in OII. We can
see a screenshot of the home page in Fig. 2 (a). In this platform there are approximately
180 problems spanning several techniques and difficulties, ranging from regional contests to IOI level. Furthermore, there are also the tests, from the first selection of OII
(schools selection), available as interactive online forms. So far we did not advertise
this platform in the schools, since we consider it in a beta testing phase. We allowed

The nation that hosts IOI can have two teams of four elements, but only one team is eligible for medals.
www.discourse.com
9
https://github.com/veluca93/oii-web/
10
http://www.gnu.org/licenses/agpl
11
https://registry.hub.docker.com/u/veluca93/oii-web/
12
www.docker.com
8

oii-web: an Interactive Online Programming Contest Training System

213

b
Fig. 2. The home pages of two of the platforms based on oii-web: the one for the teachers
(a) and the one for the students (b).

students to register freely, and so far we have approximately 1.500 users despite the lack
of promotion.
DIGIT is the platform dedicated to teachers: we realized this platform in a project sponsored by the MIUR, where the aim was to build a self-paced online course of computer
programming, focused on the Olympiads in informatics. The idea was to train the teach-

214

W. Di Luigi et al.

ers so they would be able to train their students. Thus, this platform is currently the richest of the three, in terms of contents and functionalities. We can see a screenshot of the
home page in Fig. 2 (b). There are video lectures on C/C++ and Pascal programming,
Algorithms and Data structures, and some basic video tutorial as well including how
to use the platform to submit a solution. There are also some lecture notes, and all the
material can be distributed to students as well; the video lectures are also available on
the OII channel on YouTube. The MIUR used this platform, since October 2013, in five
distinct courses, with a sixth one scheduled to start in September 2016. So far approximately 3.000 teachers followed this course, and the effects on the OII were impressive:
the participation of students in OII preliminary stages raised from 13k to 21k.
IOI-candidates is the last platform, and the only one not publicly available, since it is
devoted to the IOI-candidates. This platform, as we mentioned before, has been the original motivation to develop the whole oii-websystem. This platform has all the problems
available to the other two platform, together with a reserved set of problems that we use
in the contests to rank the students. The students are asked not to discuss these problems
in public forum or social network, since we usually reuse them after few years.

6. Our Experience
The advantages of a training system are clear: without it, we need to give students, besides the text of the problem: the input cases, the rules for counting the points, and, in
some cases13, a code to check the correctness of the produced output. And the student
has to: run its code against every input, run the checker against each input and matching
output, check the time and memory limits, that can be a cumbersome operation for a beginner. Furthermore, even if we automatize this task, for example by a script given to the
student, there is still the problem of measuring the running times in different machines:
students can have very different hardware and it is meaningless to state time limits without knowing their hardware.
Our path began, as we mentioned before, with the needs of a training system able to
assist us with the preparation of Italian IOI-candidates. We soon realized the advantages
of such a system, as opposed to the use of an online platform like UVa Online Judge:
we simply had more control, and this leads to a more effective teaching experience. We
almost immediately decided to develop an online platform for the OII students as well,
and we enriched our basic system with more features, in order to be able to deal with a
much larger number of (averagely) less motivated students. In the beginning of 2013, the
OII-training platform went online, in the form of a publicly available beta, as we were
planning to add more features to make it more appealing for a larger audience. Almost
concurrently, the MIUR asked us to design an online course for teachers, and we im13

To check the correctness of some problems is enough to check that the output produced by the student is the
same as the output produced by the correct solution; in other cases, usually when there is more than a unique
solution for a problem, like finding a path in a graph under some constraint, it is necessary to write a checker
code that verifies the solution proposed for the given input.

oii-web: an Interactive Online Programming Contest Training System

215

mediately decided to build it around our platform. So, in the next months, we adapted
the system for the DIGIT platform, and realized the video lectures; in October 2013 we
launched the first course: the MIUR opened a call for 250 teachers to be freely allowed
to follow the course. The call was supposed to stay open for ten days, but we reached
250 teachers in the first day, and we decided to admit more. In subsequent courses, since
we observed that the server was working fine, we raised the number of teachers per
course to 700. At the end of each course there is a programming contest, and the ones
that perform above a threshold (solving three problems out of seven) are awarded with a
certification. Note that once a teacher has access to the platform, (s)he is allowed to use
it also after the end of the course. Many teachers reported us that they had fun using the
platform, and that they plan to keep on using it.
Our experience shows that the engagement in having or not a training system is
completely different: we witnessed this at all the learners levels; beginners were more
involved, and advanced learners often joined the developers community (mostly made
of tutors and former IOI contestants) to either contribute the system development or to
propose new problems. The teachers were incredibly active in the forum, exchanging tips
and solution strategies as well as mutual support. The IOI-candidates are literally eager to
contribute to the system or in the design of new problems, maybe because they see the tutors as a model, or simply because they enjoy it so much that they want to be part of it.
We also asked the IOI-candidates to adopt a past IOI problem: our goal is to have,
in the system, all the problems from past IOIs, and therefore there is a (shrinking) list of
the problems that need to be produced: in all the cases the text of the problem is available
on the web, usually together with some solution, but we need to write input generators
and fine-tune the time and space limits. Currently we have almost all the problems of
the last ten IOIs.

7. Validation of the System: A Descriptive Analysis


In this section we discuss the results of a validation of the system; we performed our
study by means of a survey technique, with a questionnaire as a tool. We focused on the
users of the OII-training platform, and we report some stats in Table 1. With active user
we denote a user that submitted at least one solution of a problem; with problem solved
we denote the number of submission that completely solved a problem.
We sent the users of the platform the link of the questionnaire in May 2016; we
had 171 users that answered, and this means almost half of the current active users. In
Table2 we report the questions and the statistics of the answers provided.
The experimental setup is based on the collection of general information about the
respondents, and on scales aiming at Satisfaction, Usability, Effectiveness, Active learning, Fun.
Where possible we used a Likert scale, with five grades: two highest, two lowest, and
an intermediate one. This allowed to separate clearly mainly positive judgements from
mainly negative ones. Exceptions (questions Q6 and Q12) are motivated by their, less
progressive nature.

216

W. Di Luigi et al.
Table 1
Some statistics about the OII-training platform
Number of registered users
Number of active users in the period Jan. 2015 May 2016
Number of active users Jan. 2016 May 2016
Problems in the system
Problems solved by users in the period Jan. 2015 May 2016
Problems solved by users in the period Jan. 2016 May 2016
Average number of problems solved per user in the period Jan. 2015 May 2016
Average number of problems solved per user in the period Jan. 2016 May 2016

1413
812
399
253
9754
6192
12
15,5

About the general satisfaction of the learners, we considered important the learners
feeling about the actual learning results. In this respect it is quite satisfactory for us
that 65% of the respondents selected mainly positive (the highest two) grades, while the
mainly negative (lowest two grades) were chosen by a 65%.
Usability of the system was marked mainly positively by a 70%, with mainly negative scores below 4%.
Of course we were mainly interested in the effectiveness shown by the system, as
witnessed by the higher number of questions dedicated to that topic. One main issue, in
that respect, is the number of problems (meaning exercises) that the learner undertook/
solved. A second issue regards the perception of the learner about having fruitful and not
tiresome sessions of use of the system.
The first above issue is met by questions Q3 and Q4. As it was expectable, there are
more exercises tried than solved: the system is not a panacea. On the other hand,
while only 1% of the respondents tried some exercises (probably between 1 and 5) with
no success, data show that 56% of the students was able to give a try between 11 and 20
problems (one third of this share) or more than 20 (two thirds of them), succeeding in
quite a respectable 47% of the whole sample. In this respect we notice that 3 learners out
of 4 that tried more than 20 exercises, succeeded in more than 20 exercises.
The second issue above (regarding fruitful and not tiresome sessions of work in the
system), is cared by questions Q5 through Q8: to some extent Q7 helps focusing the result of Q5, while Q8 does the same for Q6. From Q5 and Q7 we clearly see that (at least
the learners perception of) fruitfulness is high, with mainly negative results below 6%
and 10%, respectively for Q5 and Q7. Q7 was indeed useful in pointing out one crucial
aspect of fruitfulness (comprehension): its results sport a quite rewarding 61% of mainly
positive marks. Finally, Q6 and Q8 tell us that there is scarce perception of a session of
work in the system being tiresome or slow.
The approach to learning sought by the system is coherent with the concept of active
learning, so we thought it would be interesting to probe the perception of learners in
that respect. Question Q9 is quite direct in that respect: the results show mainly positive
response (73%, equidistributed between the two highest marks). Questions Q10 and Q11
took a less direct route to the learners attitude toward the system: the former question
wanted to reveal the induced engagement, and scores almost 64% of mainly positive
answers, while the mainly negative feedback is limited to 8%.

oii-web: an Interactive Online Programming Contest Training System

217

Table 2
List of the questions we used in the evaluation of the system.
Satisfaction
Q1. Did you find the system useful to fulfill your learning goals?
A1. Very Much: 25.1%, Quite So: 39.8%, Enough: 28.7%, A few: 4.7%, Not at all: 1.8%
Usability
Q2. Is the system simple to use?
A2. Very Much: 24%, Quite So: 46.2%, Enough: 26.3%, A few: 1.8%, Not at all: 1.8%
Effectiveness
Q3. How many problems did you tackle in the system?
A3. 0: 1.8%, From 1 to 5: 18.1%, From 6 to 10: 24%, From 11 to 20: 18.7%, More than 20: 37.4%
Q4. How many problems were you able to solve satisfactorily in the system?
A4. 0: 2.9%, From 1 to 5: 29.2%, From 6 to 10: 21.1%, From 11 to 20: 18.1%, More than 20: 28.7%
Q5. According to your perception, your sessions using the system were fruitful?
A5. Very Much: 15.2%, Quite So: 42.1%, Enough: 36.8%, A few: 4.7%, Not at all: 1.2%
Q6. According to your perception, your sessions using the system were long enough (to be fruitful), but not too
long (to be tiring)?
A6. Too long (tiring): 8.8%, Not so long (not tiring): 81.3%, Short (not tiring): 9.9%
Q7. By solving a problem, did you improve your comprehension of the algorithm or the technique involved?
A7. Very Much: 24%, Quite So: 36.8%, Enough: 29.8%, A few: 7.6%, Not at all: 1.8%
Q8. Is the system quick enough in providing response?
A8. Very Much: 25.7%, Quite So: 35.1%, Enough: 29.2%, A few: 6.4%, Not at all: 3.5%
Active Learning
Q9. I felt active in approaching the problems with the aid of the system
A9. Very Much: 35.7%, Quite So: 37.4%, Enough: 17%, A few: 8.2%, Not at all: 1.8%
Q10. The study of algorithms and related techniques is more interesting with this approach
A10. Very Much: 33.9%, Quite So: 29.8%, Enough: 28.1%, A few: 4.7%, Not at all: 3.5%
Q11. Due to the interaction with the system I have identified and trained upon central issues in the problem
solving activity, and important concepts in the solution of problems
A11. Very Much: 17.5%, Quite So: 38%, Enough: 33.3%, A few: 9.4%, Not at all: 1.8%
Fun
Q12. Using the system I felt mainly: i) Motivated, ii) Happy iii) Curious, iv) Relaxed, v) Other
A12. Happy: 15.2%, Motivated: 52.6%, Relaxed: 4.1%, Curious: 24%, Other: 4.1%
General questions
Q13. Which institution are you currently enrolled?
A13. High School: 69%, University: 9.9%, Work: 17%, Other: 4.1%
Suggestions
Q14. What would you improve in the platform?
A14. See the text
Q15. Other ideas or suggestions
A15. See the text

Question Q11 tried to connect the work in the system with the perceived gain in
terms of problem solving skills. In this case we have still more than half the sample
showing mainly positive response (56%), with 11% mainly negative and a third of the
sample set on the intermediate grade.
Since the use of systems like ours is not usual in the Italian School, we liked the idea
to fetch some reactions in relation to the fun factor. Such an investigation would be

218

W. Di Luigi et al.

more proper in game based, or gamified, systems; however, since we actually plan to
add gamified aspects (namely a badge feature), it seemed good to add a question whose
response would be more useful in future comparisons.
With respect to the present state of the system, the results are surely quite good, with
feelings of motivation (53%) and curiosity (24%) encompassing more than three quarters of the samples feedback.
We conclude this section by discussing the suggestions we received in questions Q14
and Q15. Question Q14 was What would you improve in the platform?, and users were
allowed to choose one or more of the proposed answer, that are the directions we are
working on. We report below the results (that were not mutually exclusive, as the other
questions), in order of the expressed preferences:
77.2% I would add a wiki with documentation about algorithms and related techniques.
57.3% I would add a system to help the user to choose the next problem to solve.
36.3% I would add a badge system, to show achievements using distinct badges.
12.3% I would add more problems involving Mojito, the JackRussell mascotte of
OII.
From the first of the above results we gather the obvious: of course a repository of
centralized information, about algorithms and techniques needed in the solution of the
exercises, is highly attractive. Such a development is actually in our plans, needing basically quite a lot of wear and tear in order to structure and feed the wiki, and not much
more in terms or research. Being it a wiki, however, we are planning to make it available
to contributions coming from all the members, so to make of it another opportunity for
social collaboration, and social-collaborative learning.
On the contrary, the second preferred choice (recommending system for the next
problem to solve, that would be based on the student model) is a topic for further research, met preliminary in the next section.

8. Further Developments
A work of Wang etal. (Wang etal., 2011) states the following requirements for a comprehensive program assessment system:
1) Sufficiently

extended testing, so to cover the various cases of computation.


2) Checking

on the program structure, to see that the problem specification is met,


and no cunning shortcuts bring to the correct output.
3) Accepting

and reasonably assessing programs with static errors.


4) Providing

immediate and correcting feedback.


We think that the developments in the oii-web system should ultimately fulfill
these requirements, while the present directions should deal closely with the present
purposes of the system, that is to allow non novice students to train for the contests. So
here we try and define a model to support:

oii-web: an Interactive Online Programming Contest Training System

219

A static analysis stage where solution strategies (algorithm, data structure and their
mutual feasibility) rather than syntactic/semantics errors, are considered.
An interactive communication between system and student, to help:
Developing ones capability to select solution strategies, by giving feedback
on the actual choice.
Planning a path of growth of ones skills, by suggestions about next suitable
problems to undertake.
(And dynamic testing in the usual form, as it is already done).
Problems (the exercises proposed in the various contests, yearly), Solutions (the programs proposed by the students), and ultimately the Students are modeled basing on a
tagging mechanism. Tags are the names of problems (P), the algorithms (A) and data
structures (DS) usable and/or used in the solutions (S) of problems, the contests (C), and
levels of confidence (L) in the use of combinations of As and DSs.
Teachers in charge of the organization of a contest are named gurus; students that
came out to be exemplary in a contest, and so whose choices can count when a
solution to a problem is to be assessed, are called Exemplary Peers (EPs). EPs can be
promoted as guru.
A problem is modeled as a family of strategy choices (A and DS), suitable for its
solution. Differences in that suitability can be pointed out by a weight. The weight is
computed basing on the frequency by which A/DS were chosen, and on the reputation of
who performed that choice in the related contest. Notice that the reputation of the gurus
and EPs is contextualized to the contest.
= f g
A solution submitted by a student is modeled by the strategy chosen for it:
= f g
where is either a contest name or training (off contest).
This metadata is provided by the student, in order to allow for a timely feedback
from the dynamic analysis. On the other hand that metadata might be inaccurate, so it is
subject to scrutiny: when a check points out that the data was wrong, it is changed accordingly, or (in the extreme case) the solution is removed altogether.
This check is done by gurus. A more social kind of scrutiny has been devised, yet it
cant be applied, as the students solutions submitted to the system are not to be shown in
public, at least for the time being.
A submitted solution is statically checked by comparing its specification S with that
of the problem P. A feedback can be then given, about the appropriateness of the choice,
its present weight, and possible better weighted alternatives.
The lightweight student model we can define in this framework define the skills
shown by the student while solving problems in the system; it is a collection of acquire-

220

W. Di Luigi et al.

ments each one expressing the fact that a given problem has been solved, how, how
well and in what
() = f g
where level is a discrete variable in [1 5] associated to the outcome of the dynamic
analysis of the solution submitted by the student on the problem.
The above modeling framework can be used during a contest, in order to collect
problems models and data on students (for instance to compute students reputation and
define the set of EPs for that contest).
However here we are also interested in the possible use of this framework in a social
webbased settings, to foster training in view of a next contest. The CMS would be the
place for such training, organized by the following protocol.
1. A Target Skills is given. This is a set of triples designating the aim of the the training (at this stage for all the system): = f g.
2. The trainee can access the set of problems available from previous contest, her/his
student model, and the TS.
3. While the trainee is entitled to select any problem and submit the related solution, the system can provide a list of suggestions, for best next problems to
undertake in order to enhance SM(trainee) towards coverage of TS. This list is
done by:
(a) defining the set of elements in TS that are close to be covered by tuples in SM
(Proximal Coverage PC);
(b) defining a set of problems, whose undertaking can bring to add elements in PC
to the student model.
4. Upon submission of a solution, the trainee provides its initial modeling (
).
5. The dynamic analysis of the solution establishes the level value for the t-uple

going to join the student model.
Notice that the trainee specification of the solution can be subject only to late
evaluation (by guru), in order to allow for a timely feedback coming from the dynamic analysis. So the new element in the SM is sub-judice and it could be modified or, in the extreme cases, deleted.

9. Conclusions
In this paper we introduced oii-web, an online training system for programming contests. The system is based on CMS, the grading system used currently in IOI competitions and other programming contests as well. We developed three distinct platforms,

oii-web: an Interactive Online Programming Contest Training System

221

based on oii-web, aimed at three distinct user sets: students enrolled in OII, their teachers, and IOI-candidates, i.e. the small set of students amongst which will be selected the
four to represent Italy at IOI. We discussed briefly our experience, together with some
current developments. We believe that, as happened in our case, the use of such a system
can contribute to spread the algorithmic problem solving skills needed in programming
contests.
We also believe that this tool can scale up toward being an educational support to
refining students skills in algorithm mastery, and we have presented lines of development in that direction.

Acknowledgements
We dedicate this work to Marta Genovie De Vita.

References
Casadei, G., Fadini, B., Vita, M. (2007). Italian olympiads in informatics. Olympiads in Informatics, 1, 2430.
Combfis, S., Wautelet, J. (2014). Programming trainings and informatics teaching through online contests.
Olympiads in Informatics, p. 21.
Dagien, V. (2010). Sustaining informatics education by contests. In: Teaching Fundamentals Concepts of Informatics. Springer, 112.
Garcia-Mateos, G., Fernandez-Aleman, J.L. (2009). Make learning fun with programming contests. In: Transactions on Edutainment II. Springer, 246257.
Halim, S., Halim, F. (2013). Competitive Programming, Third Edition. Lulu.com.
Hristova, M., Misra, A., Rutter, M., Mercuri, R. (2003). Identifying and correcting java programming errors
for introductory computer science students. In: Proceedings of the 34th SIGCSE Technical Symposium on
Computer Science Education (SIGCSE 03). ACM, New York, NY, USA, 153156.
Khirulnizam, A., Md, J. (2007). A review on the static analysis approach in the automated programming assessment systems. In: Proc. Nat. Conf. on Software Engineering and Computer Systems. Pahang, Malaysia.
Leal, J., Silva, F. (2003). Mooshak: a web-based multi-site programming contest system. Software: Practice
and Experience, 33, 567581.
Maggiolo, S., Mascellani, G. (2012). Introducing cms: a contest management system. Olympiads in Informatics, 6, 8699.
Maggiolo, S., Mascellani, G., Wehrstedt, L. (2014). Cms: a growing grading system. Olympiads in Informatics,
8, 123131.
Naud, K., Greyling, J., Vogts, D. (2010). Marking student programs using graph similarity. Computers and
Education, 54, 545561.
Skiena, S.S., Revilla, M.A. (2003). Programming Challenges: The Programming Contest Training Manual.
Springer Science & Business Media.
Wang, T., Su, P., Ma, X., Wang, Y., Wang, K. (2011). Ability-training-oriented automated assessment in introductory programming course. Computers and Education, 56, 220226.
Watson, C., Li, F., Godwin, J. (2012). Bluefix: Using crowd-sourced feedback to support programming students
in error diagnosis and repair. In: Proc. Int. Conf. on Web-based Learning, ICWL 2012, LNCS (vol. 7558).
Springer Verlag, 228239.

222

W. Di Luigi et al.

W. Di Luigi holds a Bachelor of Science with Honours in Computer


Science and Engineering from the University of Bologna, and hes now
attending a Masters degree in Computer Engineering at Politecnico di
Milano. He has been involved in the training of the Italian IOI team for
the last four years, and helped organizing three Italian Olympiads in
Informatics. He is one of the core developers of oii-web.
G. Farina participated in IOI 2012 and IOI 2013. He is attending a
Bachelor degree in Control Engineering at Politecnico di Milano. He
has been actively involved in the training of high school students and
of the Italian IOI team for the past four years. He helped organizing
several Italian competitions in Informatics, including the Italian Olympiads in Informatics.
L. Laura is involved in the training of the italian team for IOI since
2007, and since 2012 he is in the organizing committee of the Italian Olympiads in Informatics. He got a Ph.D. in Computer Science
in Sapienza, and currently teaches Web-based Systems Design in
Tor Vergata university of Rome and Information Systems in LUISS
university of Rome.
U. Nanni is professor of Enterprise Information System in Sapienza
University, President of the Information Engineering bachelor degree
in Latina location, Director of the Research Center for Distance Education and Technology Enhanced Learning in Unitelma Sapienza.
His research interests include: graph algorithms and their applications,
elearning models and technologies, data- text- and business- intelligence. He was PI of the LLP project eLF-eLearning Fitness.
M. Temperini is an associate professor of Engineering in Computer
Science at Sapienza University. He teaches programming techniques
and programming languages for the Web. He got a Ph.D. in Computer
Science at Sapienza. His research activity is on Web-based distance
learning, adaptive e-learning, social and collaborative learning, and
Web-based participatory planning. He has been workpackage leader and/
or national research unit coordinator in several international projects.
L. Versari participated in IOI 2012, winning a silver medal. He is attending a Masters degree in Informatics at the University of Pisa and
he is a student at the Scuola Normale Superiore. He has been involved
in the training of the Italian IOI team for the last four years, helped organizing three Italian Olympiads in Informatics. He is one of the core
developers of oii-web.

Olympiads in Informatics, 2016, Vol. 10, 223230


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.14

223

Bridging the Gap Between Bebras and Olympiad:


Experiences from the Netherlands
Willem van der VEGT
Dutch Olympiad in Informatics
Windesheim University for Applied Sciences
PO Box 10090, 8000 GB Zwolle, The Netherlands
e-mail: w.van.der.vegt@windesheim.nl
Abstract. While the number of contestants in the Dutch Olympiad in Informatics was declining, the number of participants in the Bebras contest grew rapidly. In order to reach these Bebras
participants for joining the Olympiad, several steps were taken. We analyzed the differences between the contests. We offered Bebras contestants an introductory course in programming. And we
changed he contest format of the first round of the Olympiad, introducing two new types of tasks.
As a result, the number of contestants increased and girls returned to the Olympiad.
Key words: Bebras contest, Olympiad in Informatics.

1. Introduction
The Dutch Olympiad in Informatics was initiated in 1991 as a contest for selecting
participants for the International Olympiad in Informatics. In the early years of its existence, the number of participants grew to just below 200. Since 2000 the number of
contestants in the first round of the contest has varied, but it is proven to be hard to attract
more pupils in high school for the Olympiad.
In 2005 the Netherlands was among the first countries to join Lithuania in the Bebras
Challenge. Over the last 10 years the number of participants has grown rapidly to over
21000. A lot of contestants of the Olympiad also participated in the Bebras contest. We
started looking into how we could persuade other Bebras-contestants into joining the
Olympiad as well.
Naturally, there are large differences between the Olympiad and the Bebras contest.
It is a bit like comparing the contestants in a marathon run that are aiming for a national
championship with the grand total of recreational runners; the participation of contestants serves different goals. However, there are also similarities; both of our contests are
about algorithmic and computational thinking, and they aim to challenge the participants
to show what they are capable of.
In section 2 we will give a short history of the Olympiad and Bebras in the Netherlands and elaborate on the similarities and differences between the two contests. In sec-

224

W. van der Vegt

tion 3 we will show the measures we took to bridge the gap between these contests. In
section 4 a sample problem in our new approach will be shown. In section 5 we will present the first results of the new contest format and section 6 presents some discussion.

2. Olympiad and Bebras in the Netherlands


From 1999 till 2014 the Dutch Olympiad in Informatics (2016) had a fixed format with
three stages.
Three or four programming tasks for the first round are published on our website
in September; the final task is to design a program that can enter a tournament. Contestants can register themselves and they are able to submit their solutions till January
15th. Pupils are allowed, even encouraged, to co-operate. Our submission system is able
to handle over 10 different programming languages; evaluation is also done by this
system. However, all submissions that failed the test are inspected manually, and if the
jury is able to fix a small bug, like an IO-format, the program is re-evaluated and a small
amount of points will be subtracted (like 3 out of 100 for every fixed error). Contestants
that score at least 50% of the maximum score are allowed to join the second round. All
contestants that proceed to the second round get a certificate, and there are special prizes
for early submitters and the winner of the game tournament (Codecup, 2016).
This second round is in March at a university; two or three problems with subtasks
(van der Vegt, 2009) have to be solved and sometimes there are one or two more theoretical questions (van der Vegt, 2012). All languages that our system can handle are allowed. Only in very rare cases the results of the automated evaluation are overruled. The
best performing contestants are invited for a trainings course in April on algorithms and
problem solving. They will need to switch to C++ or Pascal for the training course and
to prepare themselves for the IOI. Finally, the third round in May or June with a limited
number of contestants is used to determine the team for the next IOI.
Like in many countries, organizing the Bebras contest is done by the organizers of
the Dutch Olympiad in Informatics. The Bebras Challenge was first held in Lithuania
(Dagien, 2006). The Netherlands started with a test contest in 2005. The contest grew
rapidly, in 2015 over 1.3 million pupils from more than forty countries participated in
their national Bebras. The questions used in these contests are chosen from an international task pool. The contest is about computer science, algorithms, structures, information processing and applications. No prior knowledge is required. Criteria for good
Bebras tasks are formulated by Dagien and Futchek (2008). Dagien and Stupurien
(2016) give an overview of current research on Bebras.
Contestants compete in their own age division. In the Netherlands contestants have
40 minutes to complete 15 tasks. These can be multiple choice questions, questions
where an answer has to be given in the form of an integer or a short string, or interactive
questions. The contest runs for a week; the best performing contestants for every age
division are invited at a university for a second round (Beverwedstrijd, 2016).
All contestants in the second round get a certificate. In the IOI-style, 1/12 of them
get a gold certificate, 1/6 a silver one and 1/4 bronze. The overall winner in each age
category wins a gadget with a text inscription showing he or she was the winner of this
years Bebras contest in a specific agegroup.

Bridging the Gap Between Bebras and Olympiad; Experiences from the Netherlands

225

Performing in the Olympiad takes a reasonable amount of time; our research suggests that a typical contestant can use 20 to 80 hours to write the programs for the first
round, tough experienced pupils can easily, within a few hours, create solutions that
score well enough to proceed to the second round. A contestant in the Bebras contest
does one round in 40 minutes.
The questions differ accordingly. Most of the tasks in the Olympiad require writing either a batch or a reactive program. So knowledge of a programming language is
required. For Bebras, no prior knowledge is needed. The tasks however tend to test the
perception of concepts of computer science and computational thinking. Barendsen et al.
(2015) showed that it is possible to use Bebras tasks to assess the understanding of these
concepts; in their research they focused especially on algorithms.
Another difference was the participation of girls. Until 2004 the Dutch delegation
for the IOI used to be a mixed team (Maggiolo, 2015). In later years there was no possibility to create such a team, because the girls almost completely disappeared out of the
contest. In Bebras we reached many girls, around 40% of the contestants every year. In
the highest age group this is around 20%.

3. Bridging the Gap


We decided to work on different changes to try to get more Bebras contestants in the
Olympiad. Now we are connected with the contestants in Bebras, we can invite them as
talented pupils to try the tasks of the Olympiad. But since most of them will not be able to
write a program, we now offer a programming course for interested pupils. We give contestants a link to the Dutch translation of the Canadian Computer Science Circles (2016).
This is an interactive website designed for student to learn programming in Python.
To give these newcomers a challenge, we had to add a series of tasks on a lower difficulty level. We call these tasks the A-tasks.
We also introduced a new kind of tasks in the first round of the Olympiad, tasks that
have the look and feel of a Bebras task, but with a problem that we think will not be
solved within a few minutes. You can solve the task without using a computer, but it
could also be possible to write a computer program to help solving the problem for you.
These tasks are called the B-tasks.
The three tasks of the type we used to offer in the Olympiad are now the C- and Dtasks. An overview is given in Table 1. So we still offer a few hard programming tasks,
Table 1
Tasks in the first round of the Dutch Olympiad in Informatics
Task type

Description

Number of tasks

Points per task

Points per group

A
B
C
D

Introductory programming tasks


Theoretical, Bebras-like tasks
Advanced programming tasks
Game programming task

5
4
2
1

40
50
100
100

200
200
200
100

226

W. van der Vegt

but we want to attract new contestants in two ways: as starting programmers, after taking the course, solving A-tasks and getting curious about the other tasks we are offering, or as experienced Bebras-contestant, with a few challenging, more time consuming
puzzles. We hope that this entices the pupils to try a few programming tasks.
When we started this approach in 2014, we had no clue how many contestants we
would be able to attract. We stated in our contest description that the top 100 contestants
with a certificate would be invited to the second round, tough the last year we had over
100 contestants in the Olympiad was 2003.
We decided to combine the certification system of Olympiad and Bebras, but we set
boundaries in advance, so a contestant will know where to aim. We give every contestant
that solved all A-tasks or all B-tasks bronze certificate. Performing well for both types is
enough for silver. The boundaries are stated in Table 2.

4. Output only Problems: an Example


The Bebras-like theoretical tasks are like the output only tasks at the IOI. On the Wiki
of the International Olympiad in Informatics (2016) this definition is given. A task is
of type output only if the contestant is provided with the input files, and must only
submit the corresponding output files. The contestant can solve each test case by hand
or by writing one or more programs in the language of his choice, and doesnt need
to submit these programs. In our contest we will not use input and output files; the
contestant has to download the problem description and to submit the answer in our
contest system.
For the first tasks we used exercises that were based on the tasks Dungeon, Palindromes and Cities from Burton (2010) and Coins from Kubica and Radoszewski
(2010). Since there is a large period in time that these tasks can be solved in the first
round, we could not simple use one instance of these tasks. So we decided to make
these tasks personalized. The contest ID of a contestant was used as a random seed to
create a problem instance.
Two other restrictions were made:
1. For a full score (50 points) a submission had to be made within a week after the
problem statement was generated by the contest system. Each day of delay gives a
penalty of 1 point.
2. To discourage guessing, submitting a wrong answer gives a penalty of 10 points. A
new submission is only allowed after 24 hours.
Table 2
Boundaries for certificates
Type of certificate

Total score

Bronze
Silver
Gold

200399
400599
600700

Bridging the Gap Between Bebras and Olympiad; Experiences from the Netherlands

227

The header of a downloaded problem instance is shown in figure Fig. 1. It shows the
date and time of production, as well as the username of the contestant.
For task B4: Woorden leggen, Crosswords, a contestant had to place six give
words on a 10 by 10 grid, each letter in a different cell, in the way a crossword puzzle
or a Scrabble board is filled. All words had to be connected and no unintended short
words should appear. The number of cells in the smallest enclosing rectangle had to be
submitted.
Four of the six given words were the same for all contestants. The other two were
selected out of a dictionary; the total length of the two words was 13 and each of the
words had at least a length of 5. If our program discovered that this problem instance had
no valid solution, another one was created.
This is of course a tricky problem. There are many suboptimal solutions, so a contestant has to be really convinced before submitting. The average score for this task was
much below that of other B-tasks, as shown in Table 3.
In our second round, we take one of the B-tasks of the first round and we extend it
to a programming task with several subtasks. This way contestants are already familiar
with the problem behind the task. In the second round in 2016 we had a programming
task Crosswords with 6 subtasks. Input were a diagram with a filled in crossword and a
dictionary file with allowed words.
A. Count the empty cells.
B. Count the number of different letters used.
C. Count the number of different words used.
D. Make a list of all words, in a specific order.

Fig. 1. Header of a problem instance.


Table 3
Scores for B-tasks
ID

Title

No solution Incorrect

<=20% <=50% <=100% 100%

Average

20142015 B1
20142015 B2
20142015 B3
20142015 B4
20152016 B1
20152016 B2
20152016 B3
20152016 B4

Maze
Palindromes
Cities
Coins
Radio mast
Connections
Subsequence
Crossword

26
36
39
43
29
42
47
63

0
1
0
0
1
6
0
8

78,94%
72,52%
74,99%
72,37%
78,41%
72,43%
73,97%
53,11%

45
14
8
8
26
15
17
53

4
2
1
1
1
3
5
3

24
42
24
23
56
37
30
56

83
87
110
107
107
117
121
37

is is of course a tricky problem. There are many suboptimal solutions, so a contestant has to be really convin
fore submitting. The average score for this task was much below that of other B-tasks, as shown in Table 3.

D
014-2015 B1
014-2015 B2
014-2015 B3
014-2015 B4
015-2016 B1
015-2016 B2
015-2016 B3
015-2016 B4

228

Table 3.W.
Scores
B-tasks
van derfor
Vegt

all solution
words in theIncorrect
dictionary that
can be added
in the diagram.
TitleE. Make a list ofNo
<=20%
<=50%
<=100% 100%
F. Try to fill the diagram, minimizing
the
Maze
26
45number of0empty cells.
4
24
83
Palindromes
36
14
1
2
42
A seventh subtask was output only: Produce a 10 by 10 diagram with only valid 87
Cities
39 of empty cells.
8
0
1
24
110
words, and minimize the number
Coins
43
8
0
1
23
107
Radio mast
29
26
1
1
56
107
5. Results
Connections
42
15
6
3
37
117
Subsequence
47
17
0
5
30
121
After
applying
these
changes
in
the
Olympiad,
the
number
of
participants
grew
rapidly.
Crossword
63
53
8
3
56
37

Av
78
72
74
72
78
72
73
53

Fig. 2 shows the number of contestants that earned points with their submissions.
Thetake
boundaries
we used
for giving
their
value.it A
of the par- task with
our second round, we
one of the
B-tasks
of the certificates
first roundproved
and we
extend
topart
a programming
ticipants
a bronzeare
certificate
invited
to the
round.
Tablethe
4 provides
an second roun
veral subtasks. This
way with
contestants
alreadywas
familiar
with
thesecond
problem
behind
task. In the
overview
of
certificates
and
participation.
16 we had a programming task Crosswords with 6 subtasks. Input were a diagram with a filled in crossword
In 2015words.
only 76 out of the 100 invitees competed in the second round, in 2016 we
ctionary file with allowed
invited
124
pupils
and 84 of them joined the contest.
A. Count the empty cells
The
introductory
in used
programming was a success. Between 2011 and 2014 the
B. Count the number of differentcourse
letters
average
number
of
submissions
using Python was 18%. In the last two contests it was
C. Count the number of different words used
Sowords,
a lot ofin
thea new
participants
D. Make a list45%.
of all
specific
order use the language that they were trained in. Other
contestants
kept
using
the
languages
they
knew
had
submissions in C++, C#,
E. Make a list of all words in the dictionary that
can
be already;
added inwethe
diagram
Java,
Pascal,
PHP,
Visual
Basic
and
Haskell.
F. Try to fill the diagram, minimizing the number of empty cells
was nice to see how some teachers use the A-tasks as part of their assessment for
seventh subtask wasItoutput
only: Produce a 10 by 10 diagram with only valid words, and minimize the numb
computer science education. We had at least three classes that submitted some of these
mpty cells.
tasks, with unique solutions for the participants. This is a form of collaboration that
we encourage; we think that especially the A- and B-tasks should find their way to the
Results
classroom.
Some of the contestants started with the B-tasks. About 10 % of the contestants reter applying these changes in the Olympiad, the number of participants grew rapidly. Fig. 2 shows the numbe
stricted themselves to these tasks. Since the cut-off for the second round was 240 points

ntestants that earned points with their submissions.

Fig. 2. Participation in the Olympiad before and after the new format.

Fig. 2. Participation in the Olympiad before and after the new format

e boundaries we used for giving certificates proved their value. A part of the participants with a bronze certif
s invited to the second round. Table 4 provides an overview of certificates and participation.

Bridging the Gap Between Bebras and Olympiad; Experiences from the Netherlands

229

Table 4
Results of the first round of the Olympiad
Results first round
Gold
Silver
Bronze, proceed
Bronze, not proceed
No certificate

20142015
Total
Girls

20152016
Total
Girls

13
35
54
9
71

0
0
9
2
12

23
65
36
25
71

0
1
9
6
9

Total with score


No score

182
47

23
12

220
94

25
16

Total users

229

35

314

41

in 2015 or 297 point in 2016, competing only with A- or with B-tasks could not get you
an invitation for the second round.
And the girls returned to the Olympiad! Between 2005 and 2014 we had only three
girls in our contests. None of them performed well enough that we could consider to let
them advance to the final round. Table 4 shows that we reach a reasonable number of
girls in this contest, about 12% of the participants. Alas, last year only 2 of the girls actually joined the second round. One of them scored very reasonable, the other one is still
young and has a lot of years ahead to improve.

6. Discussion
We changed the contest format for the Olympiad in order to attract more Bebras-contestants to the Olympiad. This turned out well. The number of participants was at least
tripled, the girls returned to the Olympiad and we welcomed many newcomers in programming, due to the introductory course. The certification method worked out well.
Which challenges remain?
1. We want to attract still more contestants. Given the discussions on the role of programming in education and the emphasis on computational thinking, both Bebras
and the Olympiad offer possibilities to discuss tasks and backgrounds in a classroom. In Bebras we have a good working relation with many teachers. Getting the
computer science teachers involved in the Olympiad, using for instance A-tasks as
part of the assessment, can attract more participants.
2. New forms of tasks will be needed in the near future. Informatics as a subject is
changing and developing all the time, for instance by introducing physical computing (Przybylla and Romeike, 2014) and the use of constructivists learning environments (Weigend, 2014). The contest format of the Olympiad gives a focus on
algorithms. Other topics need to find a place. So we need to keep experimenting
with new question types.

230

W. van der Vegt

3. The Olympiad is still mostly a mans world. Finding partners, like focus groups
on girls and technology, is a condition to improve the participation of girls in the
Olympiad.
The tasks we introduced in our new contest were based on the work of colleagues in
the international community. We found ready-to-use ideas, that we only had to fit into
our new approach.
Exchanging experiences within this community is and will be an important base for
further improvements.

References
Barendsen, E., Manilla, L., Demo, B., Grgurina, N., Izu, C., Mirolo, C., Sentence, S., Settle, A. Stupurien,G.
(2015). Concepts in K-9 computer science education. In: Dagien, V. (Ed.), ITICSE15: Proceedings of the
2015 ACM Conference on Innovation and Technology in Computer Science Education. ACM, New York,
NY, USA, 85116. DOI: http://dx.doi.org/10.1145/2858796.2858800
Bebras website (2016). http://bebras.org/
Beverwedstrijd (2016). (In Dutch). http://www.beverwedstrijd.nl/
Burton, B. (2010). Encouraging algorithmic thinking without a computer. Olympiads in Informatics, 4, 314.
Codecup (2016). (In Dutch). www.codecup.nl or nio3.codecup.nl
Computer Science Circles (2016). http://cscircles.cemc.uwaterloo.ca/
Dagien, V. (2006). Information technology contests introduction to computer science in an attractive way.
Informatics in Education, 5(1), 3746.
Dagien, V., Futschek, G. (2008). Bebras international contest on informatics and computer literacy: criteria
for good tasks. In: R.T. Mittermeier, M.M. Syslo (Eds.), ISSEP 2008, LNCS 5090. Springer-Verlag Berlin
Heidelberg, 1930.
Dagien, V., Stupurien, G. (2016). Bebras a sustainable community building model for the concept based
learning of informatics and computational thinking. Informatics in Education, 15(1), 2544.
Dutch Olympiad in Informatics (2016). (In Dutch). http://www.informaticaolympiade.nl
International Olympiad in Informatics (2016). Output only.
http://wiki.ioinformatics.org/wiki/Output_only
Kubica, M., Radoszewski, J. (2010). More algorithms without programming. Olympiads in Informatics, 4,
157168.
Maggiolo, S. (2015). An update on the female presence at the IOI. Olympiads in Informatics, 9, 127137.
Przybylla, M., Romeike, R. (2014). Physical computing and its scope towards a constructionist computer science curriculum with physical computing. Informatics in Education, 13(2), 241254.
van der Vegt, W. (2009). Using subtasks. Olympiads in Informatics, 3, 4448.
van der Vegt, W. (2012). Theoretical tasks on algorithms; two small examples. Olympiads in Informatics, 6,
212217.
Weigend, M. (2014). The digital woodlouse scaffolding in science-related Scratch projects. Informatics in
Education, 13(2), 293305.

W. van der Vegt is teachers trainer in mathematics and computer science at Windesheim University for Applied Sciences in Zwolle, the
Netherlands. He is one of the organizers of the Dutch Olympiad in
Informatics and he joined the International Olympiad in Informatics
since 1992. He was involved in the IOI-workshops on tasks in Dagstuhl
(2006, 2010) and Enschede (2008). He also is one of the task designers
for the Bebras contest.

Olympiads in Informatics, 2016, Vol. 10, 231235


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.15

231

Problem Solving, Presenting, and Programming:


A Matter of Giving and Taking
Tom VERHOEFF
Dept. of Math. and CS, Eindhoven University of Technology
Eindhoven, The Netherlands
e-mail: t.verhoeff@tue.nl
Abstract. Nim is a well-known two-person game, where players alternate taking items from one
of multiple piles. Finding a winning strategy for such games is a nice exercise in problem solving. Typically, the winning strategy for classical nim is explained in terms of nim sums, involving
binary notation of numbers. I explain how to understand and play a winning strategy without prior
knowledge of binary notation, which is useful when presenting this strategy in primary school.
Programming that strategy is also an interesting challenge. This can be done elegantly in a functional language that supports patterns, such as the Wolfram Language. I conclude by giving you a
variant of nim to work out yourself.
Keywords: impartial games, nim, functional programming.

1. Introduction of Problems to Solve


I teach enrichment classes in a primary school. The focus is on problem solving. One
of the themes is puzzles and games that allow a mathematical analysis. Sometimes we
work on exotic (less known) puzzles and games, such as the princess on a graph,
Perfect (2011), and others, Dore etal. (2010). But of course it is also important to address the classics.
One of these all-time classics is the following two-person game, known as misre
nim1, played as follows:
Start with several piles of items (go stones, pennies, toothpicks, etc.).
Players alternate turns.
At each turn, a player takes one or more items from one pile.
The player taking the last item loses.
Nim is an impartial game, in the sense that the set of available moves depends only on
that state of the piles, and not on whose turn it is. The problem is to find a winning strategy:
decide which positions are a win for the first player, and how to play in such positions.
1

https://en.wikipedia.org/wiki/Nim

232

T. Verhoeff

This can be formulated as a programming problem, where you need design and implement a function to select a move for a given game position. It can also be offered as
a reactive task, Verhoeff (2009).
However, the problem that I first want to address is how to present a winning strategy
that does not require prior knowledge of binary notation, so that it can be explained to
pupils in primary school.

2. Presenting a Simple Solution


Impartial games are mathematically well understood via the Sprague-Grundy Theorem2, especially for normal play, where the player who cannot move loses. But in this
article we use the misre rule: the player who cannot move wins, making it a bit more
interesting.
When only piles of size 1 remain, it is easy to see how the game proceeds. When
the number of size-1 piles is even, the player to move wins, and loses when it is odd.
Therefore, when all piles except one have size 1, the player to move can win, viz. by
taking away from the larger pile such that an odd number of piles of size 1 remain, i.e.,
by taking away all or all-but-one items from the larger pile.
What remains to analyze are game positions with at least two piles whose size is
larger than 1. It turns out (some explanation will follow) that in this case we need to
break each pile into distinct groups whose size is a power of 2. Traditionally, this is accomplished by writing the pile size in binary notation.
However, I felt that too complicated to explain in primary school. And then it struck
me that there is an easy way to avoid binary notation. For each pile, we are going to form
groups as follows:
1. Break the pile down into groups of size 1.
2. Repeatedly combine two groups of equal size into one group.
3. This terminates when all group sizes are different.
Observe that it is an invariant of this process that the group sizes are powers
of 2: Initially, in Step 1, the group sizes are 1=20, and in Step 2 the group size
doubles: 2 2=2+1. The number of groups is a suitable variant function, which
decreases in each iteration of Step 2, proving loop termination. Note that this is a
non-deterministic algorithm.
Once all piles have been broken down into such groups, proceed as follows:
1. For each group size, determine how often such groups occur.
2. Consider the largest group size that occurs an odd number of times.
3. If no such group exists, the position is lost; otherwise, proceed with Step 4.
4. Start by removing already 1 item from a pile that has a size- group.
5. Regroup the remaining items of that group as explained above.
6. For all group sizes in pile , do the following:
2

https://en.wikipedia.org/wiki/Sprague?Grundy_theorem

Problem Solving, Presenting, and Programming: A Matter of Giving and Taking


# size- groups
in total
in
0
1
1
2
2

...
even
odd
even
odd

233

Remove from
does not happen
0 size- groups
1 size- group
2 size- groups
1 size- group

7. After this move, all group sizes occur an even number of times. Hence, it leaves a
lost position.
Breaking down the group of size 1=2 1 in Step 5, you obtain groups of
all sizes 2 with . Therefore, in Step 6 every group size occurs at least
once.
By the way, this also explains why these groups sizes, being powers of 2, are useful. But do note that there is no need to know about powers of 2 to carry out these
algorithms.

3. Programming the Simple Solution


In a functional programming language that supports patterns, the first algorithm, which
splits a pile into groups, can be elegantly expressed. Here it is using the Wolfram Language, Wolfram (2016):
(* Create groups of 1, given the pile size n *)
singletons[n_Integer] := Table[{1}, n];
(* Combine two equal groups, using a pattern *)
combine[{x___, a_, y___, a_, z___}] := {x, Join[a, a], y, z};
(* Do nothing if no equal groups are present *)
combine[list_List] := list;
(* Repeatedly combine equal groups until no more change *)
combineStar[list_List] := FixedPoint[combine, list];
(* Split a pile of size n *)
split[n_Integer] := combineStar @ singletons @ n;
(* Split all piles in a position *)
split[position_List] := Map[split, position];
Some examples:
singletons[5]
{{1}, {1}, {1}, {1}, {1}}
combine[{{1}, {1}, {1}, {1}, {1}}]
{{1, 1}, {1}, {1}, {1}}

234

T. Verhoeff

split[5]
{{1, 1, 1, 1}, {1}}
split[{3, 4, 5}]
{{{1, 1}, {1}}, {{1, 1, 1, 1}}, {{1, 1, 1, 1}, {1}}}
The second algorithm, which determines whether a position is won and how to move
is equally elegant.
(* Reduce by removing a pair of equal groups *)
reduce[{x___, a_, y___, a_, z___}] := {x, y, z};
(* Do nothing if no equal groups are present *)
reduce[list_List] := list;
(* Repatedly reduce a list until no more change *)
reduceStar[list_List] := FixedPoint[reduce, list];
(* Determine the nimsum of a list *)
nimsum[list_List] := reduceStar @ Catenate @ list;
(* Determine whether a position is won *)
won[position_List] := nimsum @ split @ position != {};
(* Move to make, if position is won and
has at least two groups of size > 1 *)
move2[position_] :=
Block[{s, ns, mx, i},
s = split @ position;
ns = nimsum @ s;
(* Determine largest group in ns *)
mx = First @ MaximalBy[ns, Length];
(* Determine index of pile with group mx *)
i = First @ FirstPosition[s, mx];
(* Replace pile i with nimsum of that pile and ns *)
ReplacePart[position, i -> Total[nimsum @ {ns, s[[i]]}, 2]]
];
An example
nimsum @ split @ {3, 4, 5}]
{{1, 1}}
won[{3,4,5}]
True
move2[{3,4,5}]
{1, 4, 5}
Programming move1 that moves optimally when at most one group has a size greater
than 1 is left as an exercise.
I admit that it takes some time to get acquainted with functional programming. But
once you do, it does pay off.

Problem Solving, Presenting, and Programming: A Matter of Giving and Taking

235

4. Conclusion
Finding a simple way for presenting a solution to a problem can in itself benefit from
problem solving. I have applied this to presenting an optimal strategy for classical nim,
a well-known taking game. Finally, I have shown how this strategy can be expressed in
the Wolfram Language using functional programming.
Let me finish by giving you a new challenge. In classical nim, a player must take one
or more items from exactly one pile. Here is a less well-known variant: at each turn, the
player must take one or more items from one or two piles. Find the winning positions for
the first player and how to determine a winning move.
While you are at it, the game Chomp3, is still unsolved, in the sense, that we do not
know how to determine a winning move for the first player (although it has been proven
that the first player can win).

References
Dore, R. etal. (2010). Math puzzles for dinner. MathOverow, 24 Jun. 2010. (Accessed 19 Jun. 2016)
http://mathoverflow.net/questions/29323/math-puzzles-for-dinner/
Perfect, C. (2011). Solving the princess on a graph puzzle. Blog, 15 Dec. 2011. (Accessed 19 Jun. 2016)
http://checkmyworking.com/2011/12/solving-the-princess-on-a-graph-puz
Verhoeff, T. (2009) 20 Years of IOI competition tasks. Olympiads in Informatics, 3, 149166.
Wolfram (2016). Wolfram Language. (Accessed 20 Jun. 2016) http://www.wolfram.com/language

T. Verhoeff is Assistant Professor in Computer Science at Eindhoven


University of Technology, where he works in the group Software Engineering & Technology. His research interests are support tools for verified software development and model driven engineering. He received
the IOI Distinguished Service Award at IOI 2007 in Zagreb, Croatia,
in particular for his role in setting up and maintaining a web archive of
IOI-related material and facilities for communication in the IOI community, and in establishing, developing, chairing, and contributing to
the IOI Scientific Committee from 1999 until 2007.
3

https://en.wikipedia.org/wiki/Chomp

Olympiads in Informatics, 2016, Vol. 10, 237247


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.16

237

REPORTS

Gomel Training School for Olympiads


in Informatics
Michael DOLINSKY
Department of Mathematics, Gomel State University Fr. Skaryna
Sovetskaya str., 104, Gomel, 246019, Republic of Belarus
e-mail: dolinsky@gsu.by
Abstract. The article describes technology used to teach programming and preparing for olympiads in informatics. Remarkable feature is a balanced education of four age ranges (preschoolers,
grades 14, grades 58, grades 911) in four directions thinking, mathematics, programming,
algorithmization and permanent Internet competitions to improve motivation. Distance learning
system DL.GSU.BY is the effective technical base of the teaching.
Keywords: programming teaching, olympiad in informatics, distance learning tools.

1. Introduction
The author has been training pupils of different ages for the in programming and preparing them for olympiads in informatics in Gomel School 27 since September of 1996 and
with help of the Distance Learning system DL.GSU.BY (further DL) since September
of 1999.
The primary goals and objectives of this process are as follows:
To develop in each child such properties as willingness to learn, analytical skills,
self-dependence, and creativity.
To give each child the base computer literacy.

238

M. Dolinsky

To help each child to understand what is programming and to decide whether his/
her professional future will be with computer programming or without it.
To prepare everybody who invests sufficient time to reach medals of national and
international olympiads in informatics.
The results of this work during 19962015 are reflected in the following achievements of pupils of Gomel and Gomel region (Performance Statistics, 2015):
More than one hundred pupils chosen programming as profession.
Dozens of pupils entered universities without exams.
189 diplomas and 32 honorable mentions from national Olympiad in Informatics
of Belarus.
37 diplomas of international collegiate programming contests (Sankt-Petersburg,
Russia).
8 gold, 11 silver and 8 bronze medal of International Olympiad in Informatics
(IOI).
Table 1 below lists the medal results from IOI 19972015 of the teams of different
regions of Belarus as well as Minsk team and team of the Lyceum of Belarus State University separately represented on national Olympiad in Informatics of Belarus.
Important hallmark of the Gomel training school for olympiads in informatics is the
start of learning as early as possible. It provides earlier (grade 10 or earlier) successes in
the olympiads including IOI (all from city of Gomel unless noted otherwise):
Aliaksei Danchanka (grade 9): 1998 participation, 1999 silver, 2000 silver.
Mikhail Svarycheuvski (10): 2000 silver, 2001 bronze.
Raman Dzvinkouski (9): 2002 bronze.
Uladzimir Miniailau (9): 2005 silver, 2006 gold, 2007 silver.
Henadzi Karatkevich (5): 2006 silver, 20072012 gold.
Uladzislau Padtsiolkin (9): 2011 silver, 2012 silver, 2013 bronze.
Siarhei Kulik (9, from Mozyr1): 2001 silver, 2012 bronze, 2013 gold.
Table 1
Medals from the national olympiad

Region

Total

Gomel region
Minsk region
Lyceum of BSU
Vitebsk region
Minsk
Grodno region
Brest region
Mogilev region

28
11
9
7
5
4
1
0

9
1
1
0
0
0
0
0

11
5
3
3
3
2
0
0

8
5
5
4
2
2
1
0

Total

65

11

27

27

Mozyr town in Gomel Region.

Gold

Silver

Bronze

Gomel Training School for Olympiads in Informatics

239

Adam Bardashevich (10, Mozyr): 2001 silver, 2012 gold.


Fedar Karabeinikau (8): 2014 participation, the first under bronze cutoff.
Unconditionally, their success is based on their own hard work as well as their parents efforts on education and the creation of conditions for rapid growth. In addition,
the success of Mozyr pupils is strongly connected to Alexey Borunov, Mozyr coach for
programming contests. Nevertheless, the author believes that the education environment
described in this paper essentially helped everybody mentioned above and many other
medalists of national and international olympiads in informatics to achieve such remarkable results.
The remainder of the paper is structured as follows: Chapter 2 represents the authors
educational principles; Chapter 3 describes the elaborated education courses, exercise
packages and permanent Internet competitions; Chapter 4 contains the authors educational strategy; Chapter 5 represents Gomel Regional Olympiad in Informatics; Chapter
6 is devoted to newly elaborated Accelerated Learning approach to teaching; finally
Chapter 7 contains conclusions.

2. The Authors Educational Principles


This chapter describes the principles used by author to organize the teaching process.
Constancy. Lessons are held in informatics cabinet of Gomel School 27 every
Wednesday and every Sunday, even on holidays (including summer). When the author is
absent from Gomel, he gets somebody to fill in for him. The site DL.GSU.BY supports
the education process around the clock, so everyone can study anytime and anyplace at
their own convenience.
Inclusiveness. The author does not deny anyone who comes to learn. Now the lessons are organized in such a way that one can begin studying not only from the first
grade of school but also from preschool ages as young as 4 years (Dolinsky, 2013).
Efficiency. The main criteria of efficiency of lessons is the ratio of the study time
to total usage time. The author tries to organize the study so that each pupil works
hard each minute of each lesson, either learning something new or consolidating their
skills.
Individuality. The author has for many years believed that efficiency in the sense
described above can be achieved only through individual and differentiated instruction.
That is, each pupil moves on at their own rate and accordingly at any given time all pupils can be at different points of the learning process.
Self-dependence. Obviously such individuality can be achieved only though independence of learning, since a teacher physically cant immediately teach (to explain, to
listen, etc.) all pupils simultaneously, particularly if the pupils work with different materials. Furthermore, the self-dependence is an important objective of the education. By
and large, the authors view is that teaching independence is even more important than
teaching any specific knowledge. It is especially true in the area of programming where
one needs to learn and relearn all professional life.

240

M. Dolinsky

Optimality (of material selection). The author tries to select the most useful material and construct the process of studying it in the most effective system. The author
cant claim to have achieved perfection, but it is true that he does try to teach today better
than yesterday and tomorrow better than today.
Demands (to comply with the rules). Unfortunately, the list of rules is ever expanding, complicating the compliance: keep silence in the audience; know where the classes
are held; bring the notebook and pen; come to class before lesson starts, leave when the
lesson is over; do exercises himself, (dont cheat); etc.
Using the site DL.GSU.BY. Since 1999, the author has headed the development
of this project and actively used it for teaching. This approach has the following advantages:
Fast verification of solutions (from a few seconds to a few minutes) and as a result
multiplying the intensity of the teaching process.
Variety of task types differentiating the study and keeping interest of students
with different levels of preparing and motivation.
Automatic presentation of tasks and differential study (Dolinsky, 2012) the technical basis for customized education.
Teacher activity. The author tries to organize the studying process in such a way that
each student works independently as much as possible.

3. Educational Courses, Exercise Packages, and Permanent Competitions


The teaching process is based on using the distance learning system DL and includes the
following learning and training courses: Programming-professionals (individual), Programming-professionals (collegiate), Programming-beginners, Programming-professionals (individual) work on errors (W/E), Programming-professionals (collegiate)
W/E, Programming-beginners W/E, Preparing for IOI, Methods of algorithmization, Basic programming, Start to program, Informatics, and Mathematics.
The course Programming-professionals (individual) is open from beginning
of December to middle of July/August until IOI. It contains weekly Sunday 5-hour
(9:0014:00 GMT+3) individual contests tasks from past olympiads of regional level
until the first decade of January (when Gomel regional olympiad in informatics is held),
then from olympiads of national level until end of March (when national olympiad in informatics of Belarus is held), and from olympiads of international level until the close.
The course Programming-professionals (collegiate) is open from the middle of
July/August (after IOI is finished) until the end of November, when Collegiate Programming Contest in Sankt-Petersburg is held. It has weekly Sunday 5-hour (9:0014:00
GMT+3) contest with tasks from past collegiate contests.
So, the whole year (including holidays) every Sunday there is 5-hour individual or
collegiate open on-line contest for all comers. Immediately after the olympiad is finished
the tasks become available for practice in courses Programming-professionals (individual) (W/E) and Programming-professionals (collegiate) W/E, respectively.

Gomel Training School for Olympiads in Informatics

241

For participants in informatics cabinet of Gomel School 27, there is additionally interactive discussion of solutions.
Tasks are classified by themes and copied into appropriate branches of the course
Methods of algorithmization. Thus, the latter is adjusted to the trends in the development of competitions and provides targeted preparation for olympiads. In addition, the
tasks that were not solved are copied to the course Preparing for IOI.
To activate self-study and practice in the courses Methods of algorithmization and
Preparing for IOI we hold the permanent Internet competitions: Autumn Cup, Winter
Cup, Spring Cup, Summer Cup, and Whole Year Prize. In the Cups we award the three
the best pupils who solve most tasks for the season (autumn, winter, spring, summer).
In the Whole Year Prize we awarded the one pupil who solves the most tasks for the
whole year (autumn-winter-spring-summer). In the course Preparing for IOI it is insufficient to solve one task, but in addition one needs to describe their solution in the DL
forum corresponding to the subject of the task.
The courses Programming-professionals (individual) (W/E), Programming-professionals (collegiate) W/E, Methods of algorithmization, Preparing for IOI, feature Tests grants. That is, a pupil can get the test data (input data, model answer, and
program-checker) on which their solution failed. Theres a special FAQ and a dedicated
DL forum to support pupils in the situation I got the right answer on my computer, but
my solution was rejected.
For individual contests (after their end) as well as for all the courses, there are permanent result tables with links to solutions of all participants (as images to prevent copying
and resubmitting).
The DL forums have links to authors systematic descriptions of solution as well as
to descriptions by pupils of Gomel and university students.
The author elaborated a set of tutorials, two from them have been published as books
in Sankt-Petersburg (Dolinsky, 2005, 2006).
Another important aspect is the joint participation of pupils and university students
in the weekly Sunday olympiads where students are training for ACM ICPC (only for
quarter-finals and semi-finals so far).
The weekly Sunday olympiads as well as practice in other weekdays is targeted
towards medalists of national olympiad in informatics preparing for International Collegiate Programming Contests and IOI, as a rule pupils of grades 911.
For pupils of grades 58 preparing for regional olympiads is the course Basic programming with possibilities of automatic task presentation and differential study. The
exercise system has tree-like structure. Correct solution provides transition to the next
exercise. Wrong solution or pressing the button I dont know transitions the student
into subtree teaching to solve the problem. Own teaching subtrees may be settled for any
such teaching tasks. This way we provide individual differential teaching that adapts not
only to the level of preparation of a pupil but also to their current emotional and physical state. Pupils who know more and are in better shape branch less and thus advance
faster. The course Basic programming has exercise packages with differential teaching on the following topics: introduction to programming, one-dimensional arrays,
two-dimensional arrays, geometry, strings, sorting, queues. To increase the motivation

242

M. Dolinsky

of beginners, there are weekly Sunday olympiads in the course Programming-beginners from 7:00 to 20:00 (GMT+3). One can solve the same tasks for practice in the
course Programming-beginners W/E.
For pupils in grades 14 there is the learning course Start to program that largely
contains the same tasks as Basic Programming, but in essentially linear form. Most
of teaching trees are reorganized into sequences of tasks for simpler learning. There are
permanent Internet-competitions Season Cups and Whole Year Prize for learning
courses Basic Programming and Start to program. Note that in the competitions the
tasks from the learning subtrees are not counted. In the course Start to Program only
pupils of grades 14 and in the course Basic Programming only pupils of grades 18
are awarded.
The training course Informatics was created for pupils of grades 14 of Gomel
School 27. Originally there was only one package of exercises: Learning to think
(Dolinsky, 2013). But soon we started to copy exercises from Start to Program to
for more advanced pupils in Informatics. Moreover, we re-open Informatics every
academic year, which gives more possibilities to change it. So, now the course Informatics has practically the same material as the course Start to Program has, but in
a better methodological form. The course Informatics also has permanent Internetcompetitions Season Cups and Whole Year Prize where pupils of grades 14 are
awarded.
The Basic Programming, Start to program, and Informatics courses are based
on the Pascal programming language.
Finally, the course Mathematics contains different tasks in mathematics, including such exercise packages as flash tasks on mathematics of grades 15, tasks from the
international mathematics contest Kangaroo (20012015, all grades), Canadian Math
Contests (19982015, grades 711), Math from informatics. In the latter, the tasks
are from the course Programming-beginners, but reformatted so that the pupil needs
to manually enter the answer for given input data. The answers can be computed manually or using an appropriate program. For the course Mathematics there also are also
permanent Internet-competitions Season Cups and Whole Year Prize where pupils
of grades 18 are awarded.
Tables 2 and 3 represent participation statistics from 2008 to 2014.

Table 2
2008/09

2009/10

2010/11

2011/12

2012/13

2013/14

2014/15

Mathematics
Informatics
Start to program
Basic programming
Methods of algorithmization
Preparing for IOI

22
10
205
31

182
263
269
25

142
205
340
8

249
118
159
332
7

146
301
174
290
491
12

175
179
189
309
425
17

214
212
300
468
441
3

Total

237

739

695

820

1424

1294

1638

243

Gomel Training School for Olympiads in Informatics


Table 3

Programming-prof. (ind.)
Programming-prof. (col.)
Programming-beginners

2008/09

2009/10

2010/11

2011/12

2012/13

2013/14

2014/15

98
51
77

116
59
67

128
73
59

165
101
89

157
55
108

141
113
69

133
71
211

4. The Educational Strategy


Currently we are providing education for four age ranges: preschoolers (from 4 years),
junior school (grades 14), middle school (grades 58), and high school (grades 911),
in four directions: thinking, mathematics, programming, algorithmization:
Thinking. The author believes that development of thinking needs to be first
to provide higher learning efficiency. For preschoolers and juniors the training
course Informatics has special packages of exercises Learning to think, Differences, Analogy, Learning to Count, and Tangram. The courses Start to
Program and Basic Programming have embedded exercises for development
of thinking.
Mathematics. It is clear that knowledge of mathematics is important in itself,
but it is more important that development of abilities to solve mathematical
problems automatically develops effective thinking skills. On one hand, there
is training course Mathematics containing different mathematical tasks for
pupils from grade 1 to grade 11. On the other hand, training courses Informatics, Start to Program, Basic programming have special packages of
exercises where mathematics and programming are integrated. For example,
the course Informatics has packages Math (programs) for grades 15. Each
of them contains tasks from appropriate mathematics textbook, converted to
programming tasks by parameterization. To solve the task, one need to solve
it mathematically and then write the corresponding program. The course Basic Programming contains packages Kangaroo grades 34 (20012008) and
Kangaroo grades 56 (20012009) where appropriate mathematics tasks are
converted into programming tasks.
Programming. We are using the Pascal programming language to teach pupils in
grades 18. But the language is a means, not a goal. Special attention is given to
debugging technology as well as structuring of program sources to improve their
readability and understandability.
Algorithmization. Best of all we are trying to develop skills for algorithm elaboration. The second direction is study of standard algorithms. Both directions are
supported by weekly olympiad solving as well as the following practice on unsolved tasks and studying the needed theory. In addition, the course Methods of
algorithmization is strongly structured around themes and subthemes and contains
information about task sources (year, country, etc.).

244

M. Dolinsky

5. Regional Olympiads in Informatics


Since 2010 the tasks for the Gomel regional olympiad that qualifies 15 best participants
to the national olympiad are created by the national Scientific Committee. But in Gomel
region we have at least five olympiads whose tasks we prepare ourselves: in autumn two
olympiads (school and city level) for grades 111 and in spring three olympiads (school,
city, and regional level) for grades 19. For those five olympiads we introduce three age
divisions: in autumn grades 14, grades 58, grades 911; and in spring grades 14,
grades 57, grades 89. We use the tasks of olympiads for:
a. Targeted training for higher level olympiads.
b. More accurate indication to students and teachers of what and how to learn.
Tasks for grades 911 (in spring grades 89) include three groups of increasing
complexity (note that each pupil needs to try solve all tasks from all groups):
First group (5 tasks) tasks on topics from the course Basic Programming (onedimensional arrays, two-dimensional arrays, geometry, strings, greedy (simple algorithm based on sorting)).
Second group (5 tasks) tasks based on the course Methods of algorithmization: queues, recursion, dynamic programming, graphs, and brute force.
Third group (2 tasks) tasks from the course Preparing for IOI, as a rule on the
following topics (or their combinations): research, complex dynamic programming, complex data structures, and complex problems on graphs.
This approach allows participation with interest for pupils who only began to study
programming (first group of tasks). At the same time we can determine the preparation
level of those who spent more time (second group of tasks) and point everyone to the
topics that need more detailed work. Finally the third group of tasks provides engagement for all 5-hours for the most prepared students, the strategic goal for whom is preparing for international olympiad in informatics.
Tasks for grades 58 (in spring grades 57) also include three groups of increasing
complexity:
First group (5 tasks) tasks on topics from course Basic Programming: introduction to programming, one-dimensional arrays, two-dimensional arrays, geometry, sorting.
Second group (3 tasks) strings, story problem, research task.
Third group (2 tasks) implementation task from a real olympiad, queues.
For the first group the simplest tasks from each topic are chosen. It is a way to check
whether a pupil has studied the topic at all, because the task has a minimum of text and
is standard for the topic.
The second group of tasks is to differentiate pupils (who have the preparation level
to solve tasks from the first group) on the skills needed to solve the olympiad tasks.
The first important such skill is development and debugging of own algorithms. The
string processing task is one where the problem formulation is very simple and easy
to understand. The main difficulty is to formulate the solution process (algorithm) in a

Gomel Training School for Olympiads in Informatics

245

programming language. The second important skill for solving is the ability to read and
understand the task text, to differentiate the important, minor, and insignificant things, to
reformulate the problem in mathematical and programming terms. So our story problem
is the task with detailed (or even cumbersome) formulation but with very simple solution. We use simplified versions of tasks from national olympiads. The third important
skill is ability to research the solution space. The task statement may be very brief so
that it is clear what needs to be done. The main problem is to invent a way to get the
result. To get such tasks, we reformulate in programming terms tasks from international
mathematics contest Kangaroo (grades 56).
Finally, the third group of tasks checks students readiness to solve original problems
from real olympiads. First task is on implementation details from one the following topics: one-dimensional arrays, two-dimensional arrays, geometry, strings. The second is
an original task on queues.
Tasks for grades 14 also include three groups of increasing complexity:
First group (10 tasks) includes tasks from Introduction to programming (three
tasks on integers, one task on each of characters, strings, length of strings, number of characters in string) and three tasks on using Pascal standard subroutines
DELETE, COPY, POS to delete and copy strings and to find position one string
within another.
Second group (5 tasks) includes tasks on one-dimensional arrays: sum of all elements, number of elements with some feature, minimal/maximal elements, search
for the first element with some feature.
Third group (5 tasks) is to differentiate more prepared students and includes the
tasks on the following topics: two-dimensional arrays, geometry, strings, research
(base on Kangaroo tasks for grades 23), and a story problem.
Systematic and purposeful development of tasks for regional olympiads is an important means of improving the student and teacher preparation in the region.
Note that all five regional olympiads in all three age divisions are on-line events, so
usually students from all over Belarus participate in them.

6. Accelerated Learning
To improve the teaching results, recently a few new packages of tasks and exercises
were introduced:
Accelerated course 2013 includes the following topics: introduction to programming, one-dimensional arrays, two-dimensional arrays, geometry, sorting,
strings, story problem, research task. Each topic includes three parts: theoretical
minimum, tasks from Gomel olympiad for grades 14, tasks from Gomel olympiads for grades 58. Such approach allows the most capable pupils to move with
maximal speed. At the same time pupils who encounter difficulties in this course
can use the standard learning approach.

246

M. Dolinsky

Olympiads grades 58 by topic includes tasks from corresponding Gomel


olympiads, grouped by topics. It allows to see potential rating of each student and
it definitely shows to him and to his teacher the areas for further work.
Olympiads grades 911 by topic is similar to the above in composition and
purpose. It includes additional topics such as recursion, dynamic programming,
graphs, brute force, and more complex tasks (with complexity level corresponding
to national and international olympiads).
Belarus olympiads includes tasks from national olympiads of Belarus (qualification and final stages) grouped by topic and in the order of increasing complexity.
Note that we include in that course a special set of tasks with incomplete solutions.
To get the full solution of such task one needs to know special theory as well as
have good skills of developing and debugging complex algorithms. At the same
time the olympiads up to IOI dont demand full solutions for all tasks because winners are defined by sum of points. So it is important to develop skills for solving
tasks partially. We gather such tasks into special theme Incomplete solutions and
remove the tests cases that cant be solved by partial solutions. Despite the simplicity, such solution can get from 20 to 80 points and can essentially improve the
final result of a contestant in an olympiad. Moreover such simplified solutions may
be useful to verify full solution.
We believe that development of these courses is essential not only for preparing to
olympiads but also to identify flaws in the education system with a view to their eventual elimination.
Note that the author has written and documented the solutions for all tasks (for medal
minimum points) from the course Belarus olympiad and also for more complex tasks
for courses Olympiads grades 911 by topics and Olympiads grades 58 by topic.
So, if a pupil cant solve some task there are two options: ask for help from somebody
who already solved it or read the description of the authors solution.
The shortest way for a pupil from grades 58 to reach the medal level of national
olympiad in informatics of Belarus is: Accelerated course, Olympiads 911, Belarus Olympiads.

7. Conclusion
We represented the current state of the system for preparing students of Gomel and
Gomel region for olympiads in informatics as well as strategic development directions.
Note that the system is also used by pupils outside of Gomel region. A remarkable
feature is permanent monitoring of preparation state for all pupils as well as a balanced
education of four age ranges (preschoolers, grades 14, grades 58, grades 911) in four
directions: thinking, mathematics, programming, algorithmization.
To improve motivation for ongoing education, we organize the permanent Internet
competitions (Autumn-Winter-Spring-Summer, Whole Year).

Gomel Training School for Olympiads in Informatics

247

References
Dolinsky M. (2013). An approach to teach introductory-level computer programming. Olympiads in Informatics, 7, 1422.
Dolinsky M. (2014). Technology for the development of thinking of preschool children and primary school
children. Olympiads in Informatics, 8, 6368.
Dolinsky M. (2005). Algorithmization and Programming with TURBO PASCAL: From Simple to Olympiad
Problems: Tutorial. Sankt-Petersburg Piter. (In Russian).
Dolinsky M. (2006). Solving of Sophisticated Olympiad Programming Problems: Tutorial. Sankt-Petersburg
Piter. (In Russian).
Performance Statistics of Gomel Pupils in International and National Olympiads in Informatics from 1997 to
2015. (In Russian).
http://dl.gsu.by/olymp/result.asp

M. Dolinsky is a lecturer in Gomel State University Fr. Skaryna


from 1993. Since 1999 he is leading developer of the educational site
of the University dl.gsu.by. Since 1997 he is heading preparation of
the pupils in Gomel to participate in programming contests and olympiads in informatics. He was the deputy leader of the team of Belarus
for IOI2006, IOI2007, IOI2008 and IOI2009. His PhD is devoted to
the tools for digital system design. His current research is in teaching
Computer Science and Mathematics from early age.

Olympiads in Informatics, 2016, Vol. 10, 249254


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.17

249

Armenia: IOI Participation and National


Olympiads in Informatics
Vahram DUMANYAN, Armen ANDREASYAN
Department of Informatics and Applied Mathematics, Yerevan State University
1 Alex Manoogian, Yerevan, 0025, Armenia
e-mail: duman@ysu.am, andreas@ysu.am
Abstract. The article describes technology used to teach programming and preparing for Olympiads in Informatics in Armenia. It describes the current model of organizing the competition: steps,
target groups, methodologies of development, evaluation, and the preparation of participants for
the different stages of the competition.
Keywords: IOI, olympiad in informatics, teaching programming.

1. IOI Participation
Armenia started participating in the IOI in 1996 in Hungary. Next year Armenian delegation could not go to the South Africa. Our students won first medal (bronze) in 2002.
Since then they returned from an IOI with at least one medal. For us especially significant are IOI2005 when Vahe Musoyan won gold medal, and IOI2014 when all four
students won medals (2 silver and 2 bronze). Since now Armenia has 1 gold , 4 silver and
20 bronze medals. You can find all details in the Statistics page (International Olympiad
in Informatics Statistics).
Medalists of an international olympiads may enter appropriate departments of universities of the country without exams and study for free.
In the first years, team leaders found sponsors for the trip expenses. For the last 15
years, these costs are covered by the Ministry of Education.
Armenian students participate in International Zhautykov Olympiad (Iglikov et. al.,
2013) 3 silver and 7 bronze medals, and APIO 3 bronze medals.

2. National Olympiad Procedure


The National Olympiads among school student are held by the Ministry of Education
and Science. Every year the schedule of Olympiads is made. The assignments and the

250

V. Dumanyan, A. Andreasyan

results of all the school Olympiads held in Armenia are placed in (School Olympiads)
and in (Armenian Educational Portal) websites.
YSU Faculty of Informatics and Applied Mathematics is responsible for the National
Olympiad of Informatics.
National Olympiad is held in three stages. There are no divisions according to the
grade and age. The majority of the participants are students of grades 1012, but there
are also lower grade students. The first phase is the school stage and is held at schools
in February. Until 20142015 school year, the schools conducted that stage independently and chose their best students. Schoolteachers made the assignments themselves
and held the competitions. Sometimes the content and form of their assignments did not
correspond to the assignments of next rounds. There are no statistics on the number of
participants of those years.
The second stage is regional and is held in early March. Armenia is divided into 10
provinces. On this stage, the capital Yerevan is considered as a separate entity. The students of the provinces gather on the same day and the same time. They solve the problems
compiles by the Commission. Before 20142015 school year, the juries of every province
checked the results according to the provided tests and chose the best students themselves.
The biggest turnout was in Yerevan. Yerevan municipality and regional administrations
reward the winners of their regions with diplomas. Each province and the capital have
their quotas for the participation on the next stage. Yerevan has 2025 seats and each of the
provinces has 46 seats. However, some regions sent fewer students or did not send at all.
The third stage is the National. It is held in late March or early April in the computer
center of YSU. In the last 10 years, the competition is held for 2 days. As a result, best
students get rewards from the Ministry (diplomas, certificates). The Committee decides
the number of diplomas. The students that got diplomas, form the selection group.

3. New Format of Providing National Olympiads


In 2014, one of the participants of IOI2013 made new contest management system. It is
qualitatively higher than the previous system. The new system makes it possible to hold
online contests, to put interactive problems and IOI format (with subtasks) problems. It
was decided to hold the competition of all three stages of the Olympiad with this system,
and to hold the first two stages online. Any student mastering programming languages C,
C++, Pascal can take part in the first stage, informing the school administration beforehand. The list of the participants is published in the olymp.am according to the school
information.
The second stage of Olympiad is held in certain places given by the regional administrations (in Yerevan the Municipality decides the place). The students with best results
from the first stage take part in the second stage. According to the decision of the Organizing Committee, the school of the student is not taken into consideration.
The organizing committee also determines the list of participants of the third stage,
based on the results of the second one. The quotas of the provinces have been eliminated.
As a result, the number of students from Yerevan has been significantly increased.

Armenia: IOI Participation and National Olympiads in Informatics

251

4. Selection Competitions and the Preparation for the IOI


The selection group is formed according to the results of the national stage of Olympiad. Theoretical and practical classes are held for the group. Then, according to three
competitions, four students who will represent Armenia in IOI are determined. For the
preparation for the IOI 12 week summer camp is held. Last years, not only the members of IOI group take part in Summer Camp, but also the students of selection group,
that still study at school. Not only the group leaders held the lessons but also previous
years IOI medalists and participants. The Summer Camp is held at Camp Ughetsir of
Quantum College, located in the mountain resort of Aghavnadzor, as well as in the YSU
Rest House, Tsakhkadzor.

5. The Role of Online Competitions and the Online Judges


Under current conditions, it is impossible to succeed without systematic long-term studies. We think that online competitions held for the students are very useful.
Armenian National Olympiad problems can be solved in am.spoj.com. We are grateful to Spoj team for this opportunity. During our training, we use other archives too. Initially, we use Michael Dolinskis website (DOLINSKY, 2013). We would like to single
out St. Petersburg cycle of online Olympiads (Olympiads in Informatics: St. Petersburg,
Russia), USACO online contests (USA Computing Olympiad), Croatia online contests
(Croatian Open Competition in Informatics). Thanks to the organizers for giving the
Armenian translations of the competition assignments in their websites. Codeforces
competitions (Codeforces) are useful, too. It also contains numerous resources (descriptions of algorithms, virtual competitions), which are suitable for trainings.

6. Specifics of National Olympiads


Programming is a small part of School program of informatics. It is included in 11th
grade program, and it has quite superficial presentation. Informatics is not among the
examination subjects. Applicants for admission to university programming departments
have to pass mathematics and physics or English. Only a few schools have Olympic
circles of informatics.
In Armenia everything is concentrated in Yerevan: economy, science, culture, education. One can say that Yerevan dominates the provinces. The population of the provinces
is almost twice more than in Yerevan.
For last two years, it has become possible to get information about participation in
first two stages due to the online competition of regional stage. We have the following
statistics: Fig. 1, Fig. 2, Fig. 3.
The number of the participants from provinces has decreased especially in 3rd stage.

In Armenia everything is concentrated in Yerevan: economy, science, culture, education. One can say
Yerevan dominates the provinces. The population of the provinces is almost twice more than in Yerev

252

For last two years, it has become possible to get information about participation in first two stages d
V. Dumanyan, A. Andreasyan
the online competition of regional stage. We have the following statistics: Fig. 1, Fig. 2, Fig. 3.
160
140
120
100
80

Yerevan

60

Provinces

40
20
0
2015

2016

Fig. 1.
of participants
the 1st stage.
Fig. 1. Number
ofNumber
participants
at the 1statstage.
100
90
80
100
70
90
60
80
50
70
40
60
30
50
20
40
10
30
0
20

10
0

Yerevan
Provinces
Yerevan

Provinces
2015

2016

Fig. 2. Number 2015


of participants at the 2nd
2016stage.
Fig. 2.ofNumber
of participants
the 2nd stage.
Fig. 2. Number
participants
at the 2ndat stage.
The number of the participants from provinces has decreased especially in 3rd stage.
35

The number of the participants from provinces has decreased especially in 3rd stage.
30

35
25
30
20

Yerevan

25
15

Provinces

20
10

Yerevan

15
5

Provinces

10
0
5

2014

2015

2016

0
Fig. 3.
of participants
the 3rd stage.
Fig. 3. Number
of Number
participants
at the 3rd at
stage.
2014

2015

2016

Fig. 3. Number of participants at the 3rd stage.

the capital
city
there is majority
two schools.
In the
followingchart
chart you
you can
In the capitalIncity
there is
majority
of two of
schools.
In the
following
cansee
seerepresentations of
schools
in
the
republic
stage
of
National
Olympiads
in
2016:
Fig.
4.
representations of schools in the republic stage of National Olympiads in 2016: Fig. 4.

In the capital city there is majority of two schools. In the following chart you can see representations
schools in the republic stage of National Olympiads in 2016: Fig. 4.

Armenia: IOI Participation and National Olympiads in Informatics

253

3
Phys-Math School

Qauntum Collage
21

Other School

Fig.
Participantsofof3rd
3rd stage
stage of
of National
in in
2016.
Fig.
4. 4.
Participants
NationalOlympiads
Olympiads
2016.

Physics and Mathematics Specialized School is founded in 1965 by academic Artashes Shahinyan. Every
year
of the
school represent
Armenia
in thebyinternational
Physics
andstudents
Mathematics
Specialized
School is founded
in 1965
academic Artashes Shahinyan. Ev
Olympiads on Informatics,
Biology,
Astronomy.
In
year studentsMathematics,
of the schoolPhysics,
representChemistry,
Armenia in
the international
Olympiads
on Informat
Physics,
Chemistry,
Astronomy.
2015 studentsOlympiof the Phys-Math school got
2015 students ofMathematics,
the Phys-Math
school
got 14 Biology,
medals from
these In
International
medals from
Olympiads.
Quantum
is theschool
first private
ads. Quantum Collage
is thethese
firstInternational
private school
and founded
in Collage
1991. This
also school and founded
1991.
This
school
also
has
good
Olympic
history
and
traditions.
Until
2014,
has good Olympic history and traditions. Until 2014, only 12 participants from each only
of 12 participants fr
each
of
these
two
schools
were
allowed
to
take
part
in
the
second
Stage
of Olympiads. Now t
these two schools were allowed to take part in the second Stage of Olympiads. Now this
restriction is removed. The students representing Armenia in the IOI are mostly from those schools. 13
restriction is removed. The students representing Armenia in the IOI are mostly from
Armenian 25 medals are of Quantum College and 8 of Physic-Mathematical School. 24 students from
those schools. 13 of Armenian 25 medals are of Quantum College and 8 of Physic-Mathparticipants from 2003 to 2015 were of Quantum College, and 20 students of Physic-Mathemati
ematical School.School.
24 students
52 participants
fromboth
2003
to 2015
of Quantum
This isfrom
explained
by the fact that
schools
havewere
Olympic
groups that work throughout
College, and 20 school
students
of
Physic-Mathematical
School.
This
is
explained
by the fact
year.
that both schools have Olympic groups that work throughout the school year.
arethere
sure that
are talented
students
in provinces,
as there
are exclusive preceden
However, weHowever,
are surewe
that
are there
talented
students
in provinces,
too,too,
as there
are
School
student
from
the
second
city
of
Armenia,
Gyumri,
won
the
first
medal.
In
exclusive precedents. School student from the second city of Armenia, Gyumri, won the2012, a student from
southern mountainous part of Armenia, Syunik, was involved in the group and won bronze medal in I
first medal. In 2012,
a student from the southern mountainous part of Armenia, Syunik,
He gained his basic knowledge himself through the Internet.
was involved in the group and won bronze medal in IOI. He gained his basic knowledge
himself through Now
the Internet.
we think to take measures to increase the interest and the participation of province studen
Now we think
to takeinmeasures
increase
the some
interest
the participation
of provorganize
these twotostrong
schools
kindand
of distance
lessons, online
materials accessible for
students
in
the
country.
Also
we
consider
switch
to
the
two
level
contests
opening second division
ince students, organize in these two strong schools some kind of distance lessons, online
students
9-th gradeinlike
LithuaniaAlso
(Dagien,
Skupien,switch
2007), Serbia
materials accessible
for up
alltostudents
theincountry.
we consider
to the (Ili,
two 2012).
level contests opening second division for students up to 9-th grade like in Lithuania
7. Conclusion
(Dagien, Skupien,7.2007),
Serbia (Ili, 2012).

Armenia has been participating in IOI since 1995 and has achievements. In recent years, great work
the improvement of the quality of National Olympiads has been done. There are some problems with
7. Conclusion promotion of the Olympiads. Measures should be taken to spread the necessary knowledge of Informa
and to involve more students and schools in the National Olympiads.

Armenia has been participating in IOI since 1995 and has achievements. In recent years,
great work for the improvement of the quality of National Olympiads has been done.
There are some problems with the promotion of the Olympiads. Measures should be
taken to spread the necessary knowledge of Informatics and to involve more students
and schools in the National Olympiads.

254

V. Dumanyan, A. Andreasyan

References
Armenian Educational Portal. http://armedu.am
Codeforces. http://codeforces.com
Croatian Open Competition in Informatics. http://hsin.hr/coci
Dagien, V., Skupien, J. (2007). Contests in programming: quarter century of Lithuanian experience. Olympiad
in Informatics, 1, 3749.
Dolinsky, M. (2013). An approach to teaching introductory-level computer programming. Olympiads in Informatics, 7, 1422.
Iglikov, A., Gamezardashvili, Z., Matkarimov, B. (2013). International Olympiads in Informatics in Kazakhstan. Olympiads in Informatics, 7, 153162.
Ili, A., Ili, A. (2012). IOI trainings and Serbian competitions in informatics. Olympiad in Informatics, 6,
158169.
International Olympiad in Informatics Statistics. http://stats.ioinformatics.org
Olympiads in Informatics: St. Petersburg, Russia.
http://neerc.ifmo.ru/school/io/index.html
School Olympiads (in Armenian). http://olymp.am
USA Computing Olympiad. http://usaco.org

V. Dumanyan, Doctor of Sciences (Mathematics), Yerevan State


University; Dean of the Faculty of Informatics and Applied Mathematics.
Organizer of National Olympiads in Informatics (since 2013).
Leader of national team on International Olympiad in Informatics
(2007, 2010, 20132015).
Director of Armenia Subregion in the ACM ICPC Olympiads (since
2004).
A. Andreasyan, MSc in computer science from Moscow State University. Assistant professor at the Department of Programming and Information Technologies of Faculty of Informatics and Applied Mathematics of the Yerevan State University.
Organizer of the summer camps for preparing the Olympic teams. Organizer of National Olympiads in Informatics. Leader of national team
on International Olympiad in Informatics (since 2003). Coach of Yerevan State University teams in the ACM ICPC (since 2003).

Olympiads in Informatics, 2016, Vol. 10, 255262


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.18

255

Olympiads in Informatics in Republic of Moldova


Anatol GREMALSCHI1, Angela PRISACARU2, Sergiu CORLAT3
Institute for Public Policy, Chisinau, Republic of Moldova
Department of Pre-University Education, Ministry of Education, Republic of Moldova
3
Department of Informatics and Information Technologies, Tiraspol State University,
Chisinau, Republic of Moldova
e-mail: anatol_gremalschi@ipp.md, aprisacaru@gmail.com, sergiu.corlat@math.md
1
2

Abstract. This article presents the retrospective of organizing the Republican Olympiad in Informatics from the first editions. It describes the current model of organizing the competition: steps,
target groups, methodologies of development, evaluation, and the preparation of participants for
the different stages of the competition.
Keywords: informatics curricula, IOI, olympiad in informatics, teaching programming.

1. The History
Informatics was introduced into the undergraduate studies in 1985. From the beginning, the
curriculum was oriented to systematic studying the basic computing concepts: the structure of information and the basic principles of programming. This allowed the placement
of informatics in the science field. Consequently, the discipline has benefited from lots of
opportunities of organizing school contests at various levels, as well as other sciences.

1.1. Year 1987


The first Olympiad at the national level was organized in 1987. At that time, the preuniversity educational institutions had practically no computers; first editions of the
Olympiad were held based on theoretical examinations, as well as mathematical competitions. Competition topics derived from various areas of applied mathematics, theoretical computer science, logic. From edition to edition, algorithmic component became
more pronounced, the subjects were moving towards practical component to identify
computer models for problem solving in various fields.
The advent of computers in schools set the beginning of a qualitatively new stage
in informatics competitions. It became possible to implement the theoretical solutions
in a programming language and to test these solutions. The first automated evaluation
systems appeared practically immediately.

256

A. Gremalschi, A. Prisacaru, S. Corlat

1.2. Year 1996


Since 1996, students from Moldova have participated in the International Olympiad in
Informatics. This also imposed adjustments to the organizational model for the Republican Olympiad in Informatics. The IOI is the reference point from which the development
of all structural components of the national Olympiad flows: scientific component (competition tasks, evaluation), organizational (cultural, communication, scientific sessions),
technical (computer network).
During the same period, schools were implementing individual model of using computers in labs (one student one computer). This resulted in increase of the number of
pupils fond of informatics and of programming in particular. The motivation of participants at the Olympiad increased at both national and local level. The winners of
the Olympiad got national testing facilities, preferential admission to universities in the
country, various awards; and a chance to compete for participation in international competitions.

1.3. Year 2000+


The organizational principles and scientific assessment were finalized, supported by
rules and other normative acts of the Ministry of Education. The Olympiad matured
and continued to develop in line with the national curriculum of the computer science
and the Olympic principles promoted by the Organizing Committee of the IOI. In 2004
Moldova became a member of the community of the Balkan Olympiad in Informatics
and in 2007 hosted it for the first time.
In recent years the Republican Olympiad in Informatics has generated a number of
local competitions organized by various educational institutions: individual and team
programming competitions; online contests; ICT usage competitions; robotics competitions, etc. So, the number of students fond of various fields of Computing is growing.

2. Moldavian Republican Olympiad in Informatics


2.1. The Organizational Model
The Olympiad is held annually during the academic year: from September to May. The
National Olympic Committee, the composition of which is approved annually by the
Minister of Education, organizes the Olympiad. The competition is conducted in three
stages: local, regional, and national (Fig.1).
On the local and regional stage, each grade is considered a separate age group. There
are two age groups on the national stage: middle school (up to 9th grade) and high school
(grades 1012).

Olympiads in Informatics in Republic of Moldova

257

Local Stage. There is a preparation period from September to December and internal
competitions in educational institutions take place in January (p. 1.a and 1.b on Fig.1).
Regional Stage. It is organized separately in each administrative unit. Teams of the educational institutions selected at the local stage participate on the regional level. Teams
for the national stage are formed based on the results. To ensure more rigorous selection
of the teams, the contest can take place in two rounds (p. 2.a and 2.b on Fig.1).
National Stage. The participants are the teams selected in the previous stage and National Olympiad winners from the previous year. The total number of contestants varies
between 130 and 160. Traditionally a stage lasts four days, two of which are reserved
for competition. Competition sessions last between 4 and 5 hours, depending on the age
group (middle school, high school) and the difficulty of the problems. After finishing
the contest session, the participants can attend a self-assessment session, where they
check their own solutions. Any disputes that may appear are presented to the Scientific
Committee of the Olympiad. After the completion of the competition tests and resolution of disputes, the official solutions are presented. In parallel with the contest, training
sessions, book launches, meetings with representatives of software companies and other
activities are organized for team leaders (Fig. 1).
Winners of the national stage form the Extended National Team from which the National Team that participates in international competitions is selected (Fig. 1).

IOI
National team
3.b
3.a

IOI extended team


Regional International Contests (seleted teams)
Summer School (all members)

National Stage
Contest Phase.
National contest

Contest Phase. Team selection contests

Regional Stage (each region)


Preparation Phase (for selected regional team). Traning sessions.

2.b

Contest Phase. Regional contest (one or two days), team selection

2.a

Local Stage (each school)


1.b

Contest Phase. School contests, teams selection, team trainings.

1.a

Preparation Phase. Traning sessions, simulations and internal contests, on-line


contests, seminars, etc.
Fig.1. Stages of Republican Olympiad in Informatics.

258

A. Gremalschi, A. Prisacaru, S. Corlat

2.2. Target Group


According to the curriculum, the study of software modules begins only in the 9th grade.
However, taking into account the students interest in programming and the capacity of
self-learning of the gifted and highly gifted pupils, also younger children are accepted in
the competition. The youngest participant in the history of the National Olympiad was a
6th grade pupil (13 years old)1.
Informatics teachers of junior grades try to identify the pupils with skills in computer science through a variety of methods and techniques. In many cases the selection
is performed by the teacher of Mathematics, in the 6th7th grades. A study conducted by
the authors in 20112 established a high degree of correlation between the performance in
Mathematics and in Computer Science among the participants of the National Olympiad.
Also, pupils who have good results in Physics (the study of this discipline begins in the 6th
grade) show increased interest towards programming elements. Statistics compiled over
the last 12 years (Fig.2) indicate relative stabilization in the numbers of participants in the
national stage in both categories: Senior (110 on average) and Juniors (40 on average).

2.3. Competition Topics


Competition topics are selected according to the National Curriculum in Computer
Science. The problems for Local and Regional stages are prepared separately for each
grade. The problems sets for the national stage are prepared separately for the two age
groups. Usually 34 problems are proposed in each stage, to be solved by developing
programs in Pascal, C, or C++. Six problems are proposed on the national stage, in two
days of competition.

Fig. 2. Number of participants at National Stage, 20042015, by age categories.


1

Municipal Olympiad in Informatics, 2013


Didactica Pro, Nr. 4 (68), September, 2011, p.4649

Olympiads in Informatics in Republic of Moldova

259

Task topics include data structures, combinatorics, programming techniques, elements


of analysis and design of algorithms, complexity, algorithms on graphs, elementary algorithms of computational geometry, mathematical modeling, heuristics, etc. The degree
of difficulty and statements match the contestants age.

Fig. 3. The extension model of tasks domains, based on competition stages.

Fig. 4. Distribution of tasks by domains (last 15 years, Juniors).

Fig. 5. Distribution of tasks by domains (last 15 years, Seniors).

260

A. Gremalschi, A. Prisacaru, S. Corlat

Content of tasks is developed by complexity categories, to separate competitors according to the efficiency of their solutions. The number of test cases per task ranges from
5 (local and regional stages) to 1020 (national stage). The tests check the accuracy
and efficiency of the solutions by testing special cases and enforcing time limits. The
proposed model of the problem selection allows reducing the share of participants who
receive zero scores. Thus, after statistical analysis of the results of the past 10 years, a
quantitative distribution of the problems depending on the complexity was established
(Fig. 6, 7).
Evaluation: automatic, based on a local server. Participants are identified in the system
based on user accounts, generated by the system. Human intervention in the evaluation
process is excluded.

Fig. 6. Distribution of tasks by difficulty levels (last 10 years, Juniors).

Fig. 7. Distribution of tasks by difficulty levels (last 10 years, Seniors).

Olympiads in Informatics in Republic of Moldova

261

3. Conclusions
The organizational model of the National Olympiad provides the opportunity to
participate in the initial stage to all pupils who are interested in computer science,
regardless of gender, locality, type of school, nationality.
Distributions of the competition stages allow teams time to prepare between competitions.
The automatic evaluation is scalable in both directions. It was used to assess the
results of international competitions and is used regionally for training and regional
competitions3;
The organization of the post Olympiad activities provides qualitative preparation
of National Team, as demonstrated by the results achieved by Moldova during the
participation in IOI (22 bronze medals, 2 silver medals).

References:
Chistruga, Gh., Lupu, I., Gremalschi, A. (2015). Didactic digital supports for preparation in informatics. In:
Proceedings of The National Scientific Conference 85 Years of Higher Education in Moldova, Chisinau,
2425 September, 2015. 117122.
Gremalschi, A. (2001, 2002, 2003, 2004, , 2013). Republican Olympiad in Informatics. Tasks and solutions.
2001 (2002, 2003, 2004, , 2013). Chisinau, ASEM.
Prisacaru, A., Besliu, V., Bolun, I., et. al. (2014). Republican Olympiad in Informatics. Tasks and solutions.
Chisinau.
Prisacaru, A., Besliu, V., Bolun, I. et al. (2015). Republican Olympiad in Informatics. Tasks and solutions.
Chisinau.
Gremalschi, A., Corlat, S. (2011). The role of interdisciplinary in mathematics-informatics in preparing students
performance. Didactica Pro, 4(68), 4649.
Informatics. Curriculum for Secondary Education, High School. (2010). Chisinau, Stiinta.
Informatics. Curriculum for Secondary Education, Gymnasium. (2010). Chisinau, Lyceum.

Proceedings of the national scientific conference 85 years of higher education in Moldova, Chisinau,
2425 September, 2015.

262

A. Gremalschi, A. Prisacaru, S. Corlat

A. Gremalschi, PhD, professor, Technical University of Moldova;


Director, Institute for Public Policy.
Author of textbooks in Computer Science.
Coordinator of educational projects.
Organizer of National Olympiads in Informatics (since 1997).
Leader of national team on Balkan Olympiad in Informatics, International Olympiad in Informatics (since 1996).
A. Prisacaru, consultant, Department of Pre-University Education,
Ministry of Education of the Republic of Moldova.
Professor of Informatics, MSc in Informatics.
Organizer of the summer camps for preparing the Olympic teams.
Organizer of National Olympiads in Informatics (since 2013).
Leader of national team on Balkan Olympiad in Informatics (2014),
International Olympiad in Informatics (2015).
S. Corlat, MSc in Exact Sciences. Lecturer at Tiraspol State University. Research areas: computational geometry, graph theory, computer
graphics. Also involved in institutional, national and international
projects for e-Learning. Trainer of Informatics team of Orizont
Lyceum. Leader of national team on Balkan Olympiad in Informatics (2003, 2004, 2006, 2009), International Olympiad in Informatics
(2014, 2015).

Olympiads in Informatics, 2016, Vol. 10, 263278


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.19

263

IOI 2015 Report


Artem IGLIKOV, Mansur KUTYBAYEV, Bakhyt MATKARIMOV
Nazarbayev University
53 Kabanbay batyr ave., Astana 010000, Kazakhstan
e-mail: {artem.iglikov, mansur165, bakhyt.matkarimov}@gmail.com
Abstract. The International Olympiad in Informatics (IOI) is an annual international informatics
competition for individual students at schools for secondary education from various invited countries, accompanied by social and cultural programmes. We present a report on the 27th International Olympiad in Informatics, July 26 August 2, 2015, Almaty, Kazakhstan (IOI15), organized
by the Ministry of Education and Science of the Republic of Kazakhstan, Republican Scientific
and Practical center Daryn, al-Farabi Kazakh National University and supported by Mayor of
Almaty and Mayor of Almaty region. IOI15 established a new IOI record with 322 contestants
from 83 countries, participated in IOI15 and awarded by 161 medals (27 gold, 55 silver and 79
bronze), Jeehak Yoon from the Republic of Korea is absolute winner of IOI15. At IOI15 Java
was first time introduced as IOI official programming language. In this report we pointed attention
on issues happen as well as things that done well.
Keywords: IOI, programming contest, International event organization and management.

1. Introduction
IOI is one of the worlds top level Olympiads for secondary schools students, among
International Mathematical (since 1959) / Physics (since 1967) / Chemistry (since 1968)
/ Biology (since 1990) Olympiads. Initiated by UNESCO and starting from 1989 in
Pravetz, Bulgaria, IOI constantly develops, especially in the level of scientific and technical solutions. The IOIs official site is http://ioinformatics.org, for general information on IOI we refer readers to the website and the following IOI documents: IOI
Regulation1, IOI syllabus2 and the ITC/ITWG guidelines3.
The President of the Republic of Kazakhstan, Dr. Nursultan Nazarbayev, made order in 1996 on governmental support and development of secondary schools for gifted
students, and in 1998 the Government of the Republic of Kazakhstan established a new
state enterprise, Republican Scientific and Practical center Daryn with primary goal to
discover, encourage and give recognition to gifted students by developing and supporting
1

http://ioinformatics.org/rules/index.shtml
http://www.ioinformatics.org/a_d_m/isc/iscdocuments/ioi-syllabus.pdf
3
http://wiki.ioinformatics.org/wiki/HostingAnIOI
2

264

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

special educational programs and activities. Kazakhstan hosted 36th International Mendeleev Chemistry Olympiad in 2002, Almaty city. Kazakhstan subregion of the Northeastern
European Regional Contest of the ACM International Collegiate Programming Contest
was created in 2003. From 2004 in Almaty city was organized annual International Zhautykov Olympiad on Mathematics, Physics and Computer Science (IZhO, n.d.), hosted by
the Zautykov Republican Specialized Physics-Mathematics Secondary Boarding School
for Gifted Students. Kazakhstan hosted 7th Asian Physics Olympiad in 2006, Almaty, and
51st International Mathematical Olympiad in 2010, Almaty-Kokshetau-Astana. Based on
these achievements, Kazakhstan applied to IOI Executive Director as IOI potential host in
2010. At IOI10 in Waterloo, Canada, Republic of Kazakhstan was selected by IOI International Committee as IOI15 future host. Before IOI15 Kazakhstan hosted 46th International Mendeleev Chemistry Olympiad in 2012, Astana city, http://mendeleev.kz/
and 45th International Physics Olympiad in 2014, Astana city http://ipho2014.kz/.

2. IOI Host Committees


Steering Committee: Aslan Sarinzhipov, Minister of Education and Science, Chairman; Yessengazy Imangaliyev, Vice-Minister of Education and Science, Vice-Chairman;
Galymkair Mutanov, Rector of the Al-Farabi Kazakh National University; Sholpan Kirabayeva, Director of the Republican Scientific and Practical center Daryn, Secretary;
Akhmetzhan Yessimov, Mayor of Almaty city; Yerbolat Dossayev, Minister of National
Economy; Tamara Duissenova, Minister of Health Care; Kalmukhanbet Kassymov,
Minister of Internal Affairs; Asset Issekeshev, Minister of Investment and Development;
Bakhyt Sultanov, Minister of Finance; Erlan Idrissov, Minister of Foreign Affairs.
Host Scientific and Technical Committee: Bakhyt Matkarimov, Adilet Zhaksybai, Sergazy Kalmyrzayev, Ulugbek Adilbekov, Myrzakerei Miras Nazarbayev University;
Darkhan Akhmed-Zaki, Zhanl Mamykova, Natalya Surina, Erbolat Kalaman, Shyngyz
Rabat, Pavel Chekanov, Askar Akshabayev Al-Farabi Kazakh National University;
Artem Iglikov, Azizkhan Almakhan, Madyar Aitbayev, Nurlan Zhussupov, Askar Aitzhan, Yesskendir Sultanov, Bektur Suleimenov Kazakh-British Technical University;
Mansur Kutybaev International Information Technologies University; Fuad Hajiyev
ADA University, Azerbaijan; Georgiy Korneev, Nikolay Vedernikov, Gennady Korotkevich ITMO University, Russia; Egor Kulikov, Elena Andreeva Moscow State
University, Russian Federation; Michael Mirzayanov Saratov State University, Russia;
Alexander Klenin Far-Eastern State University, Russia; Ali-Amir Aldan Massachusetts Institute of Technology, USA.
50+ staff specialists from involved organizations works full time during IOI15
week. 150+ volunteers selected from active members of the host University volunteers
club (team guides, organization staff) and from former participants of IOI and other
Olympiads (HSTC volunteers).
IOI15 was fully supported by the Government of the Republic of Kazakhstan. About
2000K was reserved/allocated for IOI15 from the Ministry of Education and Science of
the Republic of Kazakhstan, $1556K was spent for the main event, including purchase

IOI 2015 Report

265

of facilities $652K and $97K for IT Infrastructure works/HSTC/Technical staff. In total,


guest fee was $93K.

3. Preparatory and IOI Present Host Actions


IOI15 website created in 2011 and general information with photos about Kazakhstan
was first time distributed at IOI11, Pattaya, Thailand. Initially IOI15 was planned in
the capital Astana, in 2014 Almaty city and al-Farabi Kazakh National University were
announced as the host of IOI15. Programming contest for 300+ onsite contestants and
10000+ submits for evaluation with full feedback is a hard task, and IOI15 was a first
case in Kazakhstan. Previous to IOI Kazakhstan experience in programming contests
organization was reported in (Iglikov et al., 2013). The following preparatory actions
was crucial: 1) using IOI CMS (Mares and Blackham, 2012; Maggiolo et al., 2014) at
national and international programming contests in Kazakhstan, Artem Iglikov recognized as IOI CMS developer; 2) organization of Asian-Pacific Informatics Olympiad
APIO14, hosted by Kazakh-British Technical University, Almaty (APIO14, 2014); 3)
hosting all-Russia team Olympiad in programming for secondary schools in Almaty at
K.Satpayev Kazakh National Technical University4. Programming language Java accepted as official programming language in various programming contests, including
ACM ICPC. Martin Mares, ISC/ITWG, evaluated Java solutions for IOI13 tasks, created by Egor Kulikov, Pavel Mavrin and others, and reported to ISC at IOI14, Taipei,
Taiwan. ISC recommended Java as official IOI15 programming language. In 2014
Egor Kulikov accepted IOI15 HSTC member invitation. In 20142015 IOI CMS development team added full support for Java.
Communications with IOI countries representatives was by e-mail and private
Google group IOI 2015 Team Leaders. List of country contact emails extracted from
the IOI Registration system, managed by Eljakim Schrijvers https://ioiregistration.org/. All foreign participants, including IOI committees and Host scientific and
technical committee (HSTC), were registered in IOI Registration system. IOI15 invitation letters was generated through IOI registration system, as well as various reports, e.g.
list of participants with relevant information, including email, meals preferences, travel
data, etc. For visa support procedures Host created forms and instructions, published on
website and distributed by email two month before IOI, visa support procedures takes
up to 30 days. Free of charge landing visa at Almaty International airport was organized
for all teams who completed required procedures.
Call for tasks was made in December 2014 with submission deadline at January 31,
2015. Contestants machines specifications and operation system image was published
in June 2015. Significant changes in IOI15 competition rules from previous IOI was
Java as official programming language, allowing multi-threaded programs at the contest time, and limits on competition print job size. 3 practice session tasks published 2
weeks before IOI15. IOI15 and 9th IOI conference programmes was published at the
host website in July.
4

http://neerc.ifmo.ru/school/russia-team/index.html

266

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

4. IOI Committees Meeting


IOI IC/ISC committees meeting organized in Almaty at February 26 March 2, 2015.
All IC/ISC members participated this event, for newly created ITC committee Host decided to organize meeting few days before IOI. IC inspected IOI15 venue, making many
objective suggestions with short checklist. IC minutes was published at IOI official web
site. 43 unique tasks submitted for IOI15, including 6 submissions from HSTC. HSTC
rejected 11 submissions, due to various reasons, and 25 tasks shortlisted for selection
by ISC. Finally, ISC selects 9 tasks for IOI15, including 3 backup tasks: Scales, Eryk
Kopczyski, Poland; Teams, Adam Karczmarz, Poland; Boxes with souvenirs, Monika
Steinova, Slovakia; Towns, Bang Ye Wu, Taiwan (IOI14 backup task); Sorting, Weidong
Hu, China; Horses, Mansur Kutybayev, Kazakhstan; Liar, Ulugbek Adilbekov and Sergazy Kalmurzayev, Kazakhstan (IOI15 backup task, opened at IZhO16 (IZhO, n.d.)).
Cultural programme of IOI committees meeting includes opera presentation Tosca and
visit of Shymbulak mountain area.

5. IOI Organization
IOI15 venue formed by nearly located al-Farabi Kazakh National University campus
with newly built Student hotel (contestants), Atakent Park Hotel (team leaders) and RitzCarlton Hotel (IOI committees, tasks authors, invited guests). Walking time between
team leaders and contestants hotels is about 25 minutes. Student hotel was opened free
of charge without meals for early arrived teams contestants from July 23. For IOI15
needs host University allocated al-Farabi library building, Director Kalima Tuenbayeva.
Teams registration was at al-Farabi library. Opening/Closing ceremonies performed in
the U.Dzholdasbekov Palace of Students. Most of activities organized in Atakent Park
Hotel for team leaders, and in host University campus for contestants. IOI Doctor (medical) room allocated in al-Farabi library and Student hotel, as well as host University
medical center was ready to serve for IOI. At IOI15 3 medical treatment cases registered. 10 air conditioning and climate control facilities was installed in competition
hall (6) and Student hotel (4). We reserved at least two rooms/halls for any IOI activity,
except single competition hall. IOI committees rooms, IOI office, translation session
hall, GA meeting hall was allocated both in Atakent Park Hotel and al-Farabi library.
Rooms in Student hotel was not identical, e.g. for 2 or 4 persons, mirrors was only on 1st
floor, etc. Rooms for girls was allocated on the 1st floor, mixing contestants from different countries, also we allocated contestants rooms starting from 1st floor based on IOI
total medals rank of countries. In hotels for adult participants most of rooms was single,
and we sorted participants by age to allocate rooms. Student cafeteria at host University
campus was allocated for contestants and team guides. For leaders breakfast was on a
residence, lunch and dinner was at Atakent Park Hotel. Lunches at contest days was
organized for all participants at host University campus. Farewell party was at Atakent
Park Hotel. Transportation was organized within IOI venue and for all excursions, for
guest excursions two big busses was allocated. There was a shortage of minibuses, and

IOI 2015 Report

267

planned hourly shuttle at IOI venue was not implemented. Life stream translation was
not at IOI15, daily video distributed with YouTube by Azhar Rakhletova, easily found
by search IOI 2015, also video/photo materials published at IOI15 website. IOI15
schedule was traditional 8 days for IOI.

6. Cultural Programme
IOI15 cultural programme includes two whole day excursions for all participants, two
whole day and 3 Almaty city excursions for guests, various sport/entertainment events
and invited lectures. Whole day guest excursions were to the Big Alma-Arasan gorge
with Nursery Sunkar, and Kazakh aul Huns. Almaty city excursions were to the
Central State Museum of Kazakhstan, Kok Tobe mountain park with panoramic view
of Almaty city, Park of 28 Guardians of Panfilovs division, Saint Ascension Cathedral,
Ykhylas Museum of Folk Musical Instruments. Day 4 excursion was to the high-mountain sports complex Medeu, including visit of Shymbulak glacier at 3000+ m above
the sea level; and Kazakh State Circus 45 years anniversary presentation. Unfortunately,
day 6 Turgen gorge mountains area excursion was canceled due to official emergency
notification on flood flow, not happen actually, and excursion was limited to acquaintance with National customs and traditions.
IOI15 Host organizing committee thanks to Chris Peterson from Massachusetts Institute of Technology for lecture How to apply to MIT (and other USA colleges) at
July 30 with various presents, e.g. books signed by MIT professors, including Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and
Clifford Stein. Kazakhstan governmental program Bolashak supports education abroad
and our students are very interested in presentations of this kind. We did not consider
this presentation as a promotion of MIT, in fact we also invited lecturers from few other
Universities and ICPC community, and only Chris Peterson comes to IOI15. It would
be better to make open announcement before IOI for similar activities.

7. 9th IOI Conference


IOI conference traditionally organized in two days during contest time in parallel with
Question/ Answers sessions at July 2830, 2015. IOI conference program published at
host website and includes 15 presentations with workshop on IOI CMS contest management system, moderated by Stefano Maggiolo, ITS member. Special session of IOI
conference was organized for Kazakhstan teachers.

8. Quarantine
During Quarantine time contestants allowed to enter Student hotel garden and IOI volunteers organized Dance club / Entertainment programme.

268

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

9. Translation Sessions
Translation sessions organized at Atakent Park Hotel. For translation we asked team
leaders to bring their own laptops, and less than 10 laptops were requested from organizers. At IOI15 was used IOI Translation system created in Taiwan for IOI14 with minor
modifications. At the first translation session a large printing queue was caused by inefficiently organized printing procedures with operator intervention, this was improved
for the second session. In the evening before contest day 2 a power outage happen in the
hotel, causing one hour delay in GA meeting start time. Fortunately, both backup and
central power recovered by power service engineers on duty, and we did not switch to
the backup plan translation hall at host University without coffee break. Translation
nights continued up to 5 a.m. In total, 454 task statements with notices was prepared during translation sessions and published at IOI15 host and IOI official websites.

10. Question/Answer Sessions


Question/Answer sessions organized at Atakent Park Hotel in parallel with IOI Conference. At IOI15 clarification forms from contestants was scanned and distributed within IOI 2015 Team Leaders Google group, being visible to all team leaders, and text
translation from any team leader who knows question language was accepted. Most of
contestants questions in fact were handled within IOI CMS, e.g. questions written in
English or any other language, known by ISC members. Only six questions from contestants were handled at Question/Answer sessions.

11. Contest Tasks


For IOI tasks preparation we used automated platform for creating programming contest problems Polygon5, developed at Saratov State University, Russia, by Michael
Mirzayanov team from 2008. Polygon automates contest tasks preparation, organizing
effective team work on tasks and preventing typical errors, and supporting user access
management, version control, issue-tracking, integration with popular test systems, contest tasks archive compilation, long-time online backups, tasks search and classification
capabilities. For security reasons separate instance of Polygon was installed by Michael
Mirzayanov on our servers with two levels of authorization.
Boxes with souvenirs. Number of subtasks: 6. First two subtasks are easy and require
basic knowledge of programming with simple logic. Third subtask could be solved by
brute force algorithm. Starting from fourth subtask, contestants have to make simple
observations about the structure of the problem. Fourth subtask has a lot of different
solutions; the most popular one could be dynamic programming with 2 states. Subtask 5
and 6 could be solved only with most important observation of the task. The difference
is in implementation details of the algorithm which could give better performance. Tests
5

https://polygon.codeforces.com

IOI 2015 Report

269

development for this problem was relatively easy. Problem has special tests for checking
correctness of solutions on important observations.
Scales. Number of subtasks: 1. This problems has no subtasks. Score for this problem
depends on effectiveness of the algorithm. We used all the available tests for this problem, which could be easily generated and grouped by subtests. 56 different scores was
on this task at IOI15 competition.
Teams. Number of subtasks: 4. First subtask could be easily solved by brute force
algorithm. The second subtask needs knowledge of well-known sorting algorithms.
Third and fourth subtasks need advanced geometry and data structure algorithms. A lot
of tests were prepared for this problem, including all corner cases. Most of tests were
prepared to test programs on time limits, which was crucial for this problem.
Horses. Number of subtasks: 5. First subtask very easy one. Starting from second
subtask contestants should make observation about algorithm structure. Second one is
just easy implementation of this algorithm. Third subtask needs another crucial observation, which helps to solve this subtask. Difference between third and second subtask is
only in constraints. The last subtasks could be solved only with advanced data structures
and programming techniques. Tests for this problem were quite tricky, because it consist
of a huge amount of corner cases. And there is a lot of space to make some mistake in
program. There are a lot of different tests that covers huge amount of occasions.
Sorting. Number of subtasks: 6. This problem has a lot of different subtasks, because
it could be solved in many different ways. Of course not all of them are efficient enough.
Most of the subtasks have some unique constraints which makes the problem easier
than the problem itself. First three subtasks dont require main observation to solve the
whole problem. Difference between these subtasks is implementation difficulty. For the
next three one needs observation about the problem structure to be successfully solved.
Each time contestant needs to make more effort using additional technique or implement
additional data structure. Problem needed only some restricted amount of tests, which
was prepared using small test generators. They cover almost all cases, including corner
cases, small cases and large testcases.
Towns. Number of subtasks: 6. This problem may be divided into more than 6 subtasks, it was decided to fix the number of subtasks on 6. Each subtask could be treated as
a different problem, because each of them has some specific constraint on some parameters. Depending on the contestant observations there might be slightly different algorithm to solve with different score. The problem was divided by most interesting cases to
solve. Tests preparation for this problem was hardest one in the contest, consisted from
the algorithm which is hard to test with fixed amount of tests, because of the randomized
solutions. Jury tried to prepare a lot of different tests that increase probability of failure
of wrong solutions. Most of them were prepared depending on wrong solutions written
by jury itself and by beta testers.
When all task statements was completed we did not write tests verification programs,
based on final constraints and separated from tests verificator, already created by tasks
developers, this caused formally invalid test cases. Initially prepared graders was not
enough secured to prevent attacks. IOI tasks analysis with test data published at IOI15
host and IOI official websites.

270

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

12. IOI System


IOI system needs low feedback time and high availability/fault tolerance and high performance/ throughput networking evaluation system, built on relatively low cost facilities. All parts of IOI15 system was reserved, 10% of laptops, 100+% of servers, 100%
network core switches and trunk lines, and 10% of network switches and network cables
to end-point devices. IOI15 facilities were purchased in 2015 by open bid according
to the laws of the Republic of Kazakhstan. Many kinds of facilities were provided by
supporting organizations. IOI15 facilities includes 1) uninterruptible power supplies:
built-in with laptops, 20 new 2kVA UPS for every network switch, 1 new Fujitsu APC
Online 20 kVA in server room, external 800kVA mobile power generator for competition
building; 2) various facilities for installation of power network in competition hall; 3)
415 HP ProBook 450 G2 laptops with external keyboard, mouse, mousepad as contestants machines/grading system workers; 4) 30+ external monitors provided for contestants by request; 5) servers: 4 new HP/ProLiant DL380Gen9, 6 new (6+) Fujitsu blade
servers; 6) 1 new Fujitsu NetApp backup storage system; 7) 14 Alcatel-Lucent 48 port
layer-2 network switches, supporting VLANs and 1 GigE Ethernet; 8) 4 Alcatel-Lucent
layer-3 10 GigE switches at network concentration points; 9) Fujitsu rack; 10) network
cables, testers, cable channels, telecommunication boxes, etc. for network installation;
11) 5 new fast color printers; 12) 5 new (+5) fast black-white printers; 13) 3 new (+7)
big Samsung monitors as information desks, network monitor, contest results online presentation, etc.; 14) 5+ projectors for presentations; 15) 10 new climate control facilities
installed, 6 in competition hall, 4 in student hotel; 16) 1 audio system for announcements
in competition hall; 17) various video/photo translation/publication facilities for public
media coverage; 18) 6 mobile communications jammers for quarantine; 19) 1 voting
system for GA meetings.
ITC/HSTC report follows: Laptops was chosen to have more modern technical characteristics than at previous IOI, and to maximize work time on battery, e.g. 15.6 display
and Core i5 CPU, and to fit in the budget. 336 laptops were allocated for contest hall, 60
for grading system, 19 for translation session and other needs. Host received similar (but
not exact) laptops about 3 months before IOI, to prepare the system and test battery work
time. The laptops arrived about 1 month before IOI. The network was not yet set up,
so we couldnt fully test the laptops at that time, we just checked that every laptop can
successfully be turned on and boots the pre-installed system. The primary servers used
for the contest were HP DL380 Gen9. Everything was installed on one server. Another
server was a full copy of the main and had database was being replicated to it, so in case
of problems we could switch to it in minutes (and nothing would be lost). Third server
was used for live backups of contestant machines; we couldnt do this on the first server
due to high load on the file system. Fourth server was used for translation sessions. We
also had blade servers and tower machines ready to use as a backup system. We used 10
Gbps network interfaces on the server with 10 Gbps switches in the server room. Switches in the contest hall all had 1 Gbps links to contestants laptops and 2 10 Gbps uplinks
to the server room. All switches outside of the contest hall were backed up, so if any one

IOI 2015 Report

271

fails network would be still up. We had several spare switches for the contest hall and
we could configure them in few minutes to replace any failed switch. All switches were
managed remotely by university network administrator. Cable network built safely using
dual camera cable raceways for both power and digital networks. Competition hall has 6
video cameras to monitor from ISC/ITC rooms.
Contestant sample images preparation: once we had the IOI15 laptops, we took 5 of
them for setting up the contestant software. Initial software setup was performed using
Ubuntu package-management software (APT). Basic software installation was scripted
(INSERT REPO LINK). Some manual configuration had to be done for setting up help
in some IDEs (INSERT MANUAL LINK). Also, several days before the IOI we updated the image. Two versions of Eclipse 3.8 and 4.4 were provided. The 3.x branch
considered to have better performance, while the 4.x branch has more features. After
the installation of software following issues was detected 1) KWrite could not open any
file for reading (fixed by installing missing KDE packages); 2) Default destination of
Java API for Eclipse, NetBeans and IntelliJ IDEA points to Oracle internet site (JDK
links was fixed in configuration); 3) Default C++ help files are 15 years old (replaced by
actual StdLibC++ help files); 4) StdLibC++ help files are not complete (additional help
files was download from http://en.cppreference.com/); 5) Free Pascal IDE has
no help files (help files was downloaded and installed); 6) Free Pascal IDE fails on debugging complex programs (not fixed); 6) Code::Blocks hangs when multiple instances
started in short period of time (not fixed). For each Editor/IDE following requirements
was checked: 1) It is possible to write, build, run and debug a programs solving Search
practice session problem on all supported languages (a lot of minor misconfigurations
found and fixed); 2) Help files are available for all supported languages (required help
files was downloaded and configured); 3) It is possible to save/load files (failed by
KWrite); 4) Printing are supported (printing is not implemented in Sublime Text editor and have bugs in Code::Blocks, to alleviate later issue contestants was instructed to
use Print to PDF or use different IDE/Text editor for printing). Keylogging software
(logkeys) was installed on contestants workstations. It allows monitoring contestant
activity before and during the contest. Some of the contestants performed activity on
theirs workstations before start of the contest (most of them unintentionally, like sleeping on keyboard) and was warned about that. The side-effect of the key logging was
ability to determine times when a contestant computer was hang. It became possible due
to timestamps that accompanies pressed keys and clear message of key logger restart.
Therefore, it is possible to determine the time of last key press before the hang-up and
first key press after it. So we have a good upper bound on hand-up time.
Imaging contestant machines: for imaging we follow Bernard Blackham report for
IOI 2013 (Blackham, 2013). We have set up a dhcp boot server (dnsmasq), which forwarded laptops to boot TinyCoreLinux from tftp server (atftpd). The imager script was
being downloaded after TCL is booted, so we didnt have to update TCL image each
time we change the imager script. The imager script wipes the partition table, re-partitions the drive, and starts udp-receiver to receive the main partition image. We were able
to re-image up to 90 machines with the speed about 900 Mbps, which for 10 GB image
took about 12 minutes. We tried to re-image all the machines at once, but this didnt

272

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

work well (probably required some nicer setup). We decided not to lose time on this and
reimaged the hall by 34 rows (each row was up to 25 machines). Even in this case it
took about 1015 minutes to reimage everything. We also didnt bother on TCL image
size and contestant image size and had no issues with it. During imaging the addressing was the following: all laptops in the VLAN 18 with addresses 10.18.row.place / 16.
Server had one interface in VLAN 18 with address 10.18.0.1 / 16. During the contest the
addressing was the following: each laptop in different VLAN (1600 + (row 1) * 100 +
place 1) and address 10.row.place.2 / 24. Server had over 300 virtual interfaces with
addresses 10.row.place.1 / 24.
All managing of contestants machines and workers was done remotely (after several
tries). We could: turn on laptops remotely with wake-on-lan (which saved us from a lot
of walking), selectively re-image laptops, start memtest or badblocks on all the laptops,
do anything we want on the laptops during the imaging script is running (thanks to
Bernard for embedding a backdoor), do anything we want on the laptops after imaging
with SSH (laptop contained servers public SSH key) or NetAdmin. To control and monitor contestant workstations we used Java-based NetAdmin tool by Georgiy Korneev. It
monitors current state of each computer in the network several times per second and
allows issuing control command to all workstations or selected part of them. There is
a command queue for each workstation, so the command executes only when workstation is accessible and all previous commands has been finished successfully. NetAdmin
allows issuing of server-side (local) and workstation-side commands (remote). Serverside command executed on server by NetAdmin itself. For example, Copy contestant
data command looks as follows: scp -r {day} {ip}:/home/ contestant, where
{day} and {ip} are placeholders for current contest day (day0, day1, or day2) and IPaddress of the computer to copy data to. By default, command executes on all computers
simultaneously, but this is not the case for Copy Contestant Data command if you try
to copy 100M simultaneously on 360 computers this will result in terrible network performance. NetAdmin is able to throttle execution of such kind of commands to specified
number of simultaneous executions. Workstations-side (remote) commands are executed
by special remote execution service, installed on controlled workstations. Both remote
execution service and NetAdmin server authorizes each other using TLS certificates.
Another option is to use ssh command on server side. An example of client-side command is Reboot: reboot -fn. Notice, that there is no need to specify exact computer to
reboot, as long as the command is run on that specific computer. NetAdmin support offline commands that executes event when workstations are not accessible. Offline commands are useful for wake-on-lan and similar scenarios. NetAdmin also has been used
to monitor and control grading system invocation workstations.
During the competition, we performed backups of contestant home directory on each
workstation. On days 1 and 2 backups scheduled to run each three minutes. During the
practice session backups was performed each minute to test network throughput and to
measure influence on contestants. Average backup of all contestant workstations took
4050 seconds, with peaks up to 60 seconds. Backups was performed using rsync incremental backups (--link-dest), this allows to make snapshots of home directory,
while preserving hard drive space and network throughput. Using this scheme the initial

IOI 2015 Report

273

backup of the single workstation has size of 300+MB. To reduce this size we implemented cross-workstation incremental backups. In this scheme we took the full backup
of only one original workstations (still 300+MB), while backups of the other workstations was made as incremental relative to original. This allows us to reduce the size
of the initial backup to 5MB/workstation. Most of this 5MB are files regenerated by
Gnome/Unity after detection of new hardware ids after reimaging. New backup scheme
allows us to dramatically reduce time and space required for the initial backup. Unfortunately, the backup time of all workstations was 57 mins, even when there are no actual
changes was made. Profiling shown than workstations CPU and network usage was
almost negligible, while performance was capped by server hard disc. Further investigation shown, that most of the time is spend by rsync to create hard link to each unmodified file during backup. To alleviate this issue we switched from Ext4 to BTRFS that
gave us 5 times boost. To speed up backups even more, we decided not to backup large
amount of files that should (almost) never change or are regenerated on startup. This two
tweaks combined reduced backup time of all workstations to 4050 sec, while decreasing workstation and network load. Test backup restore was performed several times, and
no issue was found. Unfortunately, backup restore during day 1 analysis resulted in hang
of heavily used workstations. After reboot all workstations become ok. Further investigations shown that hangs was due simultaneous update of Gnome configuration files
and cache by both user and rsync. There are two scenarios to work around this issue: 1)
Perform backup restore only when workstation is not in use. This is the main scenario in
the case of unrecoverable contestant workstations failure. In this case, restore took about
30 sec, which is small compared to time to try recovering workstation, and moving contestant to another one; 2) Restore backup to different directory. This scenario was used
on day 2 result discussions, when backups were restored to dayX/backup directories.
We used master version of CMS (which has evolved greatly during the year before
IOI15) with some modifications. Main improvement of this year was testing a submission in parallel on all the workers on different test cases. So if there are some idle workers, contestant would receive the result much faster than if it would be tested on one
worker as it was before. This lead to an issue with ES performance, but it was solved
by Stefano and Bernard before day 2. Proper patches for CMS will be posted in the official repository. Other CMS modifications included: 1) specifying subtasks inclusion in
dataset options (when subtask 2 can include all the test cases from subtask 1 according
to the task statement, that could be specified in the dataset options, and results of evaluation on test cases of subtask 1 will be included into results of evaluation on test cases
of subtask 2; 2) displaying results was done in an aggregated form (for each appeared
evaluation outcome we showed number of test cases and maximal used memory and
time); 3) Oracle JDK support; 4) many improvements for Polygon importer. There were
several problems with Java support: multi-threading, memory limit, time limit. Oracle
JDK is multithreaded by nature. During testing we observed about 17 threads required
to just start the program for Oracle JDK 8 on Ubuntu 15.10 x64. We had several choices:
1) limit number of threads with the sandbox (this would be problematic, because JVM
can start GC any moment on a separate thread); 2) limit the number of threads the contestant program is allowed to start (this should work with GC which is not being started

274

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

by contestant program, but there was a theoretical possibility that standard libraries used
by the contestant could start some threads); 3) allow multi-threading. We have chosen to
allow multi-threading and counted the execution time as the sum of execution times of
all threads of the program. This lead to an interesting issue: if the program used amount
of memory close to the JVM heap size, then JVM would start GC on a separate thread,
and its working time will be added to the total execution time. To overcome this issue
we raised memory limits and JVM heap size (both -Xmx and -Xms). Another problem is
that standard data input classes (Scanner, BufferedReader) in Java are quite slow. With
help of Egor Kulikov we re-wrote all graders to use the raw FileInputStream, buffering
and parsing the input in the grader itself. After this, surprisingly, Java input become
much faster than input on C++. So we had to rewrite C++ input procedures as well
(reading number of bytes from the input and parsing them manually). After that the same
technique was applied to FreePascal graders.

13. Competition
Day 1 and 2 contests were started at 9:00 as planned by schedule. IOI15 CMS evaluation statistics: 5762 solutions at competition day 1 evaluated in total on 325118 tests,
8845 solutions at competition day 2 evaluated in total on 470563 tests. In total 371 print
jobs from 114 contestants was executed, 9 pages was a maximum per single job. Submits statistics by tasks vs. programming languages with number of different contestants
and submits presented in Table 1. C++ used by most of contestants, and Java usage
approaches C/Pascal usage. Java perspectives may be only estimated locking usage dynamics on next IOIs.
ISC/ITC/HSTC reports on issues happen at contest time: Hardware setup, including
servers, workstations and networking was very solid. There was no major issues was
found, while several minor issues was fixed: 1) glitches on workstation screen when
the lid is moving (2 contestant, workstations were replaced); 2) heavy glitches for few
Table 1
Programming languages usage at IOI15
C++

Java

Pascal

day1

312

5278

90

81

58

boxes
scales
teams

308
281
263

2380
1503
1395

5
4
5

42
19
29

5
4
4

27
23
31

3
4
3

33
15
10

day2

312

8107

11

148

179

116

horses
sorting
towns

305
304
177

3339
3006
1762

11
6
4

61
66
21

5
4
2

70
72
37

3
4
1

22
93
1

IOI 2015 Report

275

seconds when video mode is changed (probably bug in video card drivers, does not affect contestants); 3) two contestants was provided with additional monitors (by request);
4) no mouse pads on practice session (mouse pads were provided by request on days 1
and 2; 5) workstation hang-ups (real origin is undetermined, 8 contestants was affected
during day 1, and 4 during day 2).
Day 1:
At the beginning one of 12 CMS servers was not working properly due to misconfiguration. As a result electronic statements and grading was unavailable for roughly 1/12 of
all contestants. They could still read the hard copies. This was reported around 9:15 and
fixed within ~5 minutes.
Around 9:40, a cheating case was detected. In problem Scales a contestant managed
to read the internal data of the grader. We fixed the grader, so that this type of hacking
would be much more difficult. When doing that we faced a CMS bug, which resulted in
grading not working for ~20 minutes. After that, the outstanding solutions were graded
quickly.
At 10:30 we discovered a problem in test data for task Teams. A task statement condition was not satisfied in one test case, 2 students got affected. The first one was the
one who reported the issue, so he added a workaround within few minutes. The second
student submitted a solution that solved the incorrect test 13 minutes later after his incorrectly graded submission. Some other students already passed this test. A rejudge was on
the way, but we realized that it would not finish before the end of the contest. Because of
that, around 13:40 we have announced the details of the problem.
Around 12:30 the same CMS bug has shown up. Before it got fixed, around 12:33
we had a power problem with UPS on network switches, which caused the CMS server
to be unavailable for everybody. It was fixed in about 10 minutes. During this time, the
contestants could work on their computers. After few minutes the CMS bug was fixed
(graders were restarted). Unfortunately, one contestant has to reboot his computer during
power failure period. This reboot takes a lot of time, since DHCP server was inaccessible
at this moment. It is recommended to pin dynamic IP addresses in future installations.
At 12:55 the allowed interval between submissions increased from 1 to 5 minutes
(per task). This was dropped down to 1 for the last 8 minutes of the contest. During the
second half of the contest the grading time was around 18 minutes. To the best of our
knowledge, all grading results were reported within 25 minutes.
Several computers locked up during the contest and they had to be rebooted. We
have analyzed the logs, but the reason remains mysterious (we are still investigating).
In one case, it happened during the network outage, so the machine did not come up
immediately. The student has lost about 5 minutes, so we decided to extend the contest
by 5 minutes for him. However, additional analysis of log files revealed that some other
machines could have been unusable for up to 13 minutes. They were rebooted by the
volunteers, who did neither tell us nor recorded the details, and the contestants did not
complain, so we cannot be sure how serious the problem was. The volunteers will receive better instructions for day 2.
A large number of clarification requests were received due to students not knowing
how to compile their program in their preferred environment (mostly Code::Blocks).

276

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

They had included graderlib.c and grader.cpp into their project, which caused multiple
symbols to be defined.
Public clarification actions: 1) In the beginning: Aman can give multiple souvenirs
when he is in a section; 2) Graders read I/O from file; 3) Scales grader behavior for incorrect queries; 4) Late: sample grader prints not only the sequence, but also the number
of queries; 5) Late: Teams may give bad results.
8 machines froze and got rebooted incidents of rebooting from 3 to 15 minutes.
Questions received: 1) lots of technical questions we assisted the students; 2) questions regarding the rules we gave the full answered; 3) task related questions often
answered ANSWERED IN TASK DESCRIPTION or INVALID QUESTIONS. Exceptions: questions regarding something that was clarified then we tried to provide a very
helpful answer. Question/Answer translations worked fine.
Analysis of day 1 issues: 1) some cases of freezing computers may have been caused
by Code::Blocks grabbing the keyboard and mouse and then locking. However, there
may have been other causes, too; 2) There were 4 students affected by the regrade on
Teams. To gather more information on sporadic hang-ups of contestants workstations,
the remote syslog facility was set up. Syslog analysis allows attributing some of hangups to Code::Blocks and finding the way to alleviate them. To test performance of remote syslog workstations was simultaneously rebooted several times. No missing log
messages or substantial network load was detected during reboots.
Day 2:
During the day 2 all announcements were dubbed on the screen as popups using notify-send.
There was a small issue in the sample grader for Towns. This was updated in CMS
before the contest and pushed to the machines at 09:05. 09:11: E-1 report could not
extract zip file, confirmed, using local versions for sorting at 09:15. Several issues rose
about day 2 graders, first at 09:13. There were two versions of graders; both of them
were the same. 09:32 clarifications notice that horse.out is 0/0. The .out files are results
of running sample graders, announcements made at 09:46. 09:20 ranking issue: submissions with ids from day 2 overwrote submissions from day 1. Fixed at 09:40. 11:40
Found and fixed a typo in the announcement sorting.1.in > sorting1.in. 13:07 another
ranking issue: some scores became lower after refresh. Fixed in 2 minutes. This was
likely caused by a faulty restart of one the ranking servers.
During the contest day 2, one more issue was found: the bug in Code::Blocks that
caused UI to hand while debugging some programs. Two affected contestants were instructed to use pkill in such circumstances. Recorded issues at day 2: 1) L-5 hardware
12:3612:41; 2) G-15 multiple Code::Blocks freezes (~15 min total lost) caused by the
contestant repeatedly trying the same thing; 3) J-10: 12:3012:35; 4) I-13: 13:4013:44
Code::Blocks.
ITC investigated CMS issues and reported: After the ISC confirmed the problem on
a test case for Teams, the ITC inserted new test dataset in CMS and started the background judging. The system handling the queue of submissions saw an increase in workload that exposed an application level deadlock causing frequent freezes. Therefore the
background judging proceeded slowly, and eventually it was decided to switch to the

IOI 2015 Report

277

new dataset before its judging caught up. As the rate of submission increased, the deadlock was triggering again, requesting manual intervention each time. As judging became
slower, contestants increased their submission rate as they could not wait for the (potentially positive) previous results. This forced us to increase the minimum time between
submissions to 5 minutes. The cause of the deadlock was found and fixed by Bernard
between day 1 and day 2. In parallel to this, one reason for the higher than expected
workload was CMS change to distribute each test case to a single worker, which has the
advantage of giving much lower latency when the system is relatively free. The unexpected drawback of this change, in a setting with high number of workers such as the
IOI, was that the system, handling the queue, was overwhelmed by the communication
with the workers. This problem was patched by Stefano between day 1 and day 2 (where
each evaluation was split in about half a dozen packets rather than one per test case).

14. Award Ceremony


322 IOI15 contestants awarded 161 medals, 27 gold (rounded up), 55 silver (rounded
up) and 79 bronze. Jeehak Yoon from the Republic of Korea is single absolute winner of
IOI15 with perfect score 600 from 600, he was awarded IOI trophy. IOI Distinguished
award was to Don Piele, USA, post mortem. Special presents were given to girls
IOI15 contestants (Kazakhstan tradition).

15. Conclusion
In IOI15 participated 83 Official Teams (77 teams with 4 contestants, 3 teams with 3
contestants, 2 teams with 2 contestants, 1 team with 1 contestant), 0 Observing Countries,
1 President, 1 ED, 10 IC, 8 ISC, 7 ITC, 24 HSTC; 322 Official Contestants, 161 Leaders/
Deputy Leaders, 62 Guests + 7 Invited Guests + 2 children. Hosting IOI is an exceptional
event in a lifetime experience. Thank you very much IOI community for giving us the
opportunity to show a small part of our beautiful country! Welcome Kazakhstan again!

Acknowledgements
We greatly appreciate efforts and hard work of more than 200 specialists to organize
IOI15, including staff, volunteers, engineers from the Ministry of Education and Science of the Republic of Kazakhstan, Republican Scientific and Practical center Daryn,
al-Farabi Kazakh National University, administration of Almaty and Almaty region,
ITMO, Saratov SU, Moscow SU, Far-Eastern State University, ADA University, MIT,
Kazakh-British Technical University, International Information Technologies University, Kazakhstan Hewlett-Packard office, ALSI, Albeta Kazakhstan, Emergency service
Almaty, Kazakh State Circus, Medeo & Shymbulak administration, Kazakhtelecom and
many others. Thank you very much!

278

A.V. Iglikov, M.U. Kutybayev, B.T. Matkarimov

References
IZhO (n.d.). International Zhautykov Olympiad. http://izho.kz/
Iglikov, A., Gamezardashvili, Z., Matkarimov, B. (2013). International Olympiads in Informatics in Kazakhstan. Olympiads in Informatics, 7, 153162.
Mares, M., Blackham, B. (2012). Introducing CMS: a contest management system. Olympiads in Informatics,
6, 8699.
Maggiolo, S., Mascellani, G., Wehrstedt, L. (2014). CMS: a growing grading system. Olympiads in Informatics,
8, 123131.
APIO14 (2014). Asian-Pacific Informatics Olympiad 2014. http://olympiads.kz/apio2014/
Blackham, B. (2013). Bernard Blackham report on IOI13.
http://www.ioinformatics.org/locations/ioi13/

A.V. Iglikov ISC member, Taiwan 2014, ITC member, Host Country
2015. Technical director of Kazakhstan subregion of the Northeastern
European Regional Contest of the ACM International Collegiate Programming Contest. Jury chairman of the Kazakhstan National Olympiad in Informatics, International Zhautykov Olympiad (on Computer
Science).
M.U. Kutybayev IOI Team leader of Kazakhstan 2014. ISC member, Host Country 2015. Author of task Horses (IOI 2015). Jury
chairman of the Kazakhstan National Olympiad in Informatics, International Zhautykov Olympiad (on Computer Science).

B.T. Matkarimov IOI Team leader of Kazakhstan from 2005. IC


member, Host Country 20132016. Chair of IOI 2015. Initiator and
Jury chairman of Kazakhstan subregion of the Northeastern European
Regional Contest of the ACM International Collegiate Programming
Contest. Jury chairman of the Kazakhstan National Olympiad in Informatics, International Zhautykov Olympiad (on Computer Science).

Olympiads in Informatics, 2016, Vol. 10, 279283


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.20

279

The Informatics Olympiad in Mongolia:


Training Resources for non-English
Speaking Students
Altangerel KHUDER1, Danzan TSEDEVSUREN2
School of Information, Communication Technology, Mongolian University
of Science and Technology
2
School of Mathematics and Natural Sciences, Mongolian National University of Education
e-mail: khuder@must.edu.mn, tsedevsuren@msue.edu.mn
1

Abstract. In this country report we present activities related to Mongolian team training for national and International Olympiads in Informatics. First we will outline the current conditions and
problems Mongolian team is facing today. Then we describe possible solutions to those problems.
At the end we will compare our achievements to our country report published in IOI conference
in 2007. We hope this paper will be interesting for team leaders and teachers from non-English
speaking countries.
Keywords: information and communication technology, informatics education, informatics competitions, programming contests, Informatics Olympiad, Mongolia.

1. Introduction
There are about 565 high schools and 497 000 students in Mongolia (Purevjal and Altantuya, 2013). Each year Mongolian National Informatics Olympiad is organized in
four stages: School competition, District competition, City/Province competition and
National competition. Fig. 1. shows the participant numbers for each stage. Students
with top scores are admitted to the next level.
The first National Informatics Olympiad was organized in 1987. Mongolian Informatics Association is responsible for organizing whole annual national informatics
Olympiads in cooperation with the Ministry of Education and Science, other universities and ICT companies. In 2015 weve started using CMS (Contest Management System) in our National Competition which reduced the time needed for judging and made
it less human dependable (Maggiolo, Mascellani, and Wehrstedt, 2014).
The first four winners of the national Olympiad participate in the International Olympiad in Informatics. The national winners receive scholarships to study IT at local universities (Choijoovanchig, Uyanga, and Dashnyam, 2007).

280

A. Khuder, D. Tsedevsuren

Fig. 1. Participants and structure of National Olympiad.

Professors from leading IT universities such as Mongolian National University of


Education, Mongolian University of Science and Technology and National University
of Mongolian, participate in trainings for IOI team.
Students solve 6 programming problems in two days for National competition. The
maximum score at the competition is 300 or 600 points. Fig. 2 shows the total participant
number and the percentage of the maximum score from absolute high score.
Fig. 3. shows results of the Mongolian team participation in IOIs from 2011 through
2015.

Fig. 2. Maximum score (in percentage from absolute high score) and participant number.

The Informatics Olympiad in Mongolia: Training Resources for ...

281

Fig. 3. Mongolian team results in IOI.

2. Key Issues and Problems


The following issues are the key challenges that hinder the success of Mongolian team
at the international competition:
1. Weak English language. Due to language barriers students cannot fully understand
tasks, use online internet sources and participate in online contests. Regular participation in online contests can be very useful for the development of students
programming and algorithmic skills.
In addition, online contest rankings show us the preparedness of our students at the
international level.
2. Lack of students skills and knowledge related to IOI syllabus. IOI syllabus gives
us list of knowledge that is required to solve most of the IOI problems. Lack of
knowledge on IOI syllabus results badly planned training and subsequently lack of
success at IOI.
3. Lack of highly qualified teachers to train students. The most successive former IOI
participants are going abroad after graduation to study and work. Now they work
for Google, Microsoft, Facebook, Amazon etc. This kind of brain drain takes
most of our teachers away. If former IOI participants would share their experience
with new participants it could help them much.
In the next section we will list how we have tried to improve students skills and
knowledge of IOI.

282

A. Khuder, D. Tsedevsuren

3. Improvements
Most of the problems stated in the previous section related to English language skills.
Though teaching English is not our main purpose weve started looking for websites,
online contests, which can support Mongolian language. To solve a problem student
must translate the problem into Mongolian. However, it takes a lot of time and in addition student can misunderstand the problem.
There are many online contests organized almost every day on the internet. As most
of our students are not strong in English we were interested in websites which allow us
to add problems in Mongolian language and upload the tests or just translate the problems into Mongolian language.
So far weve found following websites and contests:
1. Bebras. Last year our students were able to do the Bebras problems in their native
language and they were excited because there were enough problems to challenge
themselves. In this contest we had wide choice for the easy and hard problems
(Vegt, 2013). We think many high school students were stimulated to participate
in informatics Olympiad after their Bebras participation.
2. SPHERE online judge (www.spoj.com). In 2008 one of our committee members contacted Andrew Kosowski from Gdansk University, Poland and asked permission to translate the problems on the website into Mongolian language. Now
most of the basic level online problems in Mongolian language are on SPHERE.
Now several teachers from Mongolian can add problems and organize contest on
SPHERE servers.
3. Croatian Open Competition in Informatics (www.hsin.hr/coci). There are 7
online contests in a year and the organizers allow translators from other countries
to get the problems in English and translate into their native language before each
online contest.
4. Hackerrank. The website allows to its users to be problem setter and organize a
contest.
5. USACO. One of our contestants contacted a personal from USACO and they
agreed him to get problems before the contest and translate them into Mongolian.
6. Asia-Pacific Informatics Olympiad. The Asia-Pacific Informatics Olympiad
(APIO) is an IOI-like competition for delegations within the South Asian / Western Pacific region.
All these websites and online resources became available for us thanks to international cooperation. Therefore we think one of the best ways to improve quality of our
national team is international cooperation.
As a result of a fruitful cooperation with Russian team we got their full syllabus for
IOI preparation. Now we have translated the syllabus in Mongolian language and we
hope this will help us to organize well-planned training.
Recently some of the former contestants are coming back to Mongolia to share their
experience with other contestants. That is a good way to share their knowledge with the
next generation and this kind of feedback will help us to support continuous development of Mongolian team.

The Informatics Olympiad in Mongolia: Training Resources for ...

283

Also we have a dedicated website for our National Olympiad in Informatics so we


can save our results for later analysis (Mongolian National Olympiad NGO, 2015).

4. Summary
Compared to Mongolian report in 2007 there were following main improvements:
We introduced full IOI syllabus to students.
We have an official website for National contest.
We started using IOI judge system in National contest (CMS).
Skills and knowledge of Mongolian students are improving each year and there are
more and more students interested in Informatics Olympiad. To support them further we
will need some text book in the future.
Another future work for us is to develop international cooperation further so that our
students can participate in many more online contests in their native language. We hope
this way they can achieve good placements in IOI and become good specialists.

References
Mongolian National Olympiad NGO (2015). (In Mongolian). Retrieved 2016.04.21 from:
www.informatics.mn
Choijoovanchig, L., Uyanga, S., Dashnyam, M. (2007). The Informatics Olympiad in Mongolia. Olympiads in
Informatics, 1, 3136.
Maggiolo, S., Mascellani, G., Wehrstedt, L. (2014). CMS: a Growing Grading System. Olympiads in Informatics, 123131.
Purevjal, A., Altantuya, Y. (2013). Statistical Report 2013. Ulaanbaatar: OchirPress LLC.
Vegt, W. v. (2013). Predicting the difficulty level of a Bebras task. Olympiads in Informatics, 132139.

A. Khuder is an associate professor of the School of Information,


Communication Technology, Mongolian University of Science and
Technology. He is PhD in ICT and actively participates in the organization of Mongolian Informatics Association. His research interests
include Natural Language Processing, Operating Systems and Artificial Intelligence.
D. Tsedevsuren is Professor at School of Mathematics and Natural
Sciences, Mongolian National University of Education. He is PhD in
ICT and Educational Studies, and he is currently working as a President of this Mongolian Informatics Association. His research interests
include Informatics education, ICT in eduaction, theory and methodology of eLarning and electronic learning content development.

Olympiads in Informatics, 2016, Vol. 10, 285290


2016 IOI, Vilnius University
DOI: 10.15388/ioi.2016.21

285

Belarusian Olympiad in Informatics


Iryna KIRYNOVICH1, Aliaksei TOLSTSIKAU2
Faculty of Computer-Aided Design, Belarusian State University
of Informatics and Radioelectronics
Brovki 6, Minsk, Belarus, 220013
2
Faculty of Applied Mathematics and Computer Science, Belarusian State University
Nezavisimosty Ave. 4, Minsk, Belarus, 220030
e-mail: kirinovich.irina@yandex.ru, tolstikov@bsu.by
1

Abstract. Olympiad in Informatics has been held in Belarus since 1988 and is a high priority direction in the work with gifted students. National Olympiad in Informatics consists of four stages.
It is the most popular intellectual competition among youth in the Republic of Belarus.
Keywords: Olympiad in Informatics, trainings, selection for international competition, International Olympiad in Informatics, IOI.

1. Introduction
In 2016 the XXIX Belarusian Olympiad in Informatics was held in Mogilev, Belarus.
Belarusian team has taken part in IOI since 1990, when the II International Olympiad in
Informatics was held in Minsk. For 26 years the Republic of Belarus was represented by
63 members who were awarded by 79 medals (gold 14, silver 33, and bronze 32).1
Participation in the International Olympiads is the final step of multi-stage competition among gifted students. Participants of the first selection and training camp are determined during the final round of the national contest. In 30 days teams of the Republic
of Belarus prepare for participation in IOI, IMO, IPhO, IChO, IBO. The national contest
and the preparation for international competitions are provided by employees and students of the leading universities
National Olympiads are organized by the Ministry of education of the Republic of
Belarus.
The winners (Fig. 1) of the final stage of the competition have the opportunity to
enroll in the state universities without exams.

http://stats.ioinformatics.org/countries/BLR

286

I. Kirynovich, A. Tolstsikau

Fig. 1. The final stage of the Belarussian Olympiad in Informatics in 2016 winners of the 1st
degree diplomas. Head of Department of education of regional Executive Committee Vladimir Ryzhkov is standing in the middle of the photo.

2. National Belarusian Olympiad in Informatics


National Olympiad in Informatics is held with the aim of identifying and improving the
capabilities of the gifted students in the field of informatics and programming. The main
goals of the National Olympiad are to increase interest in learning programming, to deep
their theoretical knowledge and practical skills, to prepare students for participating in
the international competitions. Participation in all stages of the Olympiad is free for
students.
National Olympiad is held in each academic year in four stages: the first stage is the
educational establishment level, the second stage is the district (city) level, the third
stage is the regional competition, the fourth stage is the final national round.
Problems of three types are used at the stages of the National Olympiad in Informatics; each of them requires developing an algorithm for the problem and implementing it
in one of the available programming languages (C++ or Pascal). The problem of the first
type is the classic one: contestant has to write a program that reads the input and produces the answer, i.e. the contestant doesnt know which test data will be used to check
his program. The problem of the second type is a question with open tests. In problems
of this type participants have all input data, and it is necessary to provide the results of
the solution for known test data.
Solution grading for the second type problems usually uses partial scoring, the solution is compared with the optimal or best solution among all participants of the contest.
The problem of the third type is the interactive one. In problems of this type the source
code of a participant interacts with unknown to him library. Solutions obtain input and
the list of actions that should be performed using known protocol. These problems allow

Belarusian Olympiad in Informatics

287

Fig. 2. Awarding 3rd degree diplomas and medals to the holders of the final stage of the Belarussian Olympiad on Informatics 2016.

using questions required processing of input data in real-time, games, tasks, black box
interaction etc.
Between the stages of the Olympiad training camps are held to prepare students to
participate in the future stages of the competition.
The winners of each round of the Olympiad are awarded with I, II, and III diplomas
(Fig. 2). The number of winners at each stage of the contest does not exceed 45% of the
number of participants. The number of I diplomas does not exceed 20% of the number
of winners. Share of II diplomas is no more than 30%, III diplomas no more than 50%.
The actual number of winners at each stage is determined by the jury.

2.1. First and Second Stages


The first stage of the National Olympiad should be held not later than November of
the current academic year and is an internal stage in each institution of the Republic of
Belarus. At this stage all interested students take part in the competition. The best students qualify to participate in the second stage of the Olympiad in accordance with the
established quota. The problems preparation for this stage is not kept centrally so each
institution determines the format and prepares questions independently.
The second stage is the city or district level. At this stage the contest is held no later
than December of the current academic year and consists of one practical exam. The
contest problems for the second stage of the Olympiad are prepared centrally by each
regional department of education and contain usually only the classic problems. After
the second stage of the Olympiad each district forms a team to participate in the third
stage of the Olympiad.

288

I. Kirynovich, A. Tolstsikau

2.2. Third Stage


The third stage of the National Olympiad is held in each region of the Republic of
Belarus (7 in total). All participants compete on the same problem set prepared by the
Ministry of education of the Republic of Belarus. The problem of the second type (open
tests) adds to the classic problems at this stage. The competition is held in 2 practical
exams, each of them requires solving 34 questions. The problem complexity is significantly higher at this stage than at the previous one.
Each region forms a team of 15 students to perform at the final stage. In addition, the
team may be expanded at the expense of the last year contest winners (final stage), who
won diploma this year (third stage), but was not ranked in the top 15 in the region, as
well as the winners of the International Zhautykov Olympiad (Kazakhstan).
In January/February each regional team receives additional training camp for 14
days to prepare for the final stage. Students listen to the theoretical lectures on constructing algorithms, how to use data structures in the efficient way, and various branches of
mathematics and computer science. In addition to theoretical studies there are practical
exams with analysis.
Team of the Lyceum of the Belarusian State University participates in addition to the
seven regions of the Republic of Belarus in the final stage of the Olympiad.

2.3. Final Stage


The final stage of the National Olympiad is carried out by the Ministry of education
within 5 days in one of the host cities in March/April (Table 1). The contest problems at
this stage contain the interactive task in addition to the classical and open tests.
In the National Olympiad in Informatics all students shares a common rank list regardless of grade (Table 2). About 50% of the participants of the final stage of the Olympiad are graduates of secondary schools, gymnasiums and lyceums.
All students (grade 11) who won the final stage are eligible for admission to the state
universities of the Republic of Belarus without exams.

3. Preparation for International Competitions


According to the results of the final stage of the National Olympiad the list of 1012
most successful students is formed for selection and preparation of the participants of
the International Olympiad in Informatics. Camps are held in 23 phases with a total
duration of 30 days.
At the first phase of the trainings participants compete in from 10 to 15 rounds, the
complexity of the problems is close to the international level. After each round analysis is provided by coaches. In addition, training sessions are conducted with rounds of
solving different types of problems: object recognition, optimization problems, game
problems, etc. The list of the International Olympiad in Informatics participants forms

289

Belarusian Olympiad in Informatics


Table 1
Number of participants of the final stage in 20122016
2012

2013

2014

2015

2016

123

123

120

122

120

Table 2
Distribution of participants of the final stage in 20122016
Grade

2012
2013
2014
2015
2016
Partici- winners Partici- winners Partici- winners Partici- winners Partici- winners
pants
pants
pants
pants
pants

68
9
10
11

9
14
43
57

2
5
21
28

5
18
35
65

3
6
12
34

9
14
32
65

4
4
15
31

7
22
29
64

2
8
12
32

7
19
43
51

1
7
22
24

after the first camp. The team is approved by the Ministry of education of the Republic
of Belarus.
During the next camps coaches make lectures with different topics based on the
complex data structures and algorithms, usage of a contest system image provided by
IOI organizers and other. Participants continue preparation solving the competitions
from other countries and regions. The participation in training camps for students is
free.The results of the team of the Republic of Belarus in IOI over the last 5 years are
presented in Table 3.
In Belarus operates the high-tech Park, which includes more than 150 resident companies. Every year, the resident companies of the Park of high technologies take part in
rewarding winners of the final stage of the Olympiad in Informatics (Fig. 3).
The winners of the final stage of the Republican Olympiad will be awarded with cash
prize of the special Fund of the President of the Republic of Belarus for social support of
gifted students and shall be included in a national data Bank of talented youth.
The winners of the international Olympiad receive the title of Laureate of the special
Fund of the President of the Republic of Belarus for social support of gifted pupils and
students.
The presence of this title gives the right to receive a number of social benefits.
Table 3
Performance of the team of the Republic of Belarus in IOI in 20112015
2011
10 grade
10 grade
9 grade
9 grade

2012
Gold
Silver
Silver
Silver

11 grade
11 grade
10 grade
10 grade

2013
Gold
Gold
Silver
Bronze

11 grade
11 grade
11 grade
11 grade

2014
Gold
Silver
Bronze
Bronze

11 grade
10 grade
10 grade
8 grade

2015
Bronze
Silver
Bronze

11 grade
11 grade
11 grade
10 grade

Silver
Silver
Bronze
Bronze

290

I. Kirynovich, A. Tolstsikau

Fig. 3. Nine girls participated in the final stage of the Republican Olympiad on Informatics
2016. Some of them won medals. Director of the company Yandex Bel Alex Sikorsky has
congratulated the participants.

4. Conclusion
This article briefly describes the procedure for conducting the National Olympiad in
Informatics in Belarus. Description of all four stages of the competition and the schedule of training and selection camps are provided. In the Republic of Belarus National
Olympiad in Informatics is an important and significant event. Belarusian students won
lots medals at the international level.

I. Kirynovich,
associate
of engineering
engineering
I. Kirinovich,
associateprofessor
professor of
at the
the department
Department of
psychology
and
ergonomics,
Belarusian
State
University
of
Informatics
and
psychology and ergonomics, faculty of computer design, Belarusian
Radioelectronics,
has
Ph.D.
degree
in
physics
and
mathematics.
Chairman
of
State University of Informatics and Radioelectronics, PhD in Physthe
jury
at
the
final
stage
of
the
National
Olympiad
in
Informatics,
team
ics and Mathematics, national coordinator of the Bebras contest in
leader of the Republic of Belarus for participation in the International
Belarus, the Chairman of the jury of the final stage of the RepubliOlympiad in Informatics, national coordinator of the international
can Olympiad
in Informatics scientific and pedagogical leader for the
informatics contest "Bebras". Areas of research: simulation and optimization
preparation
team
of the Republic
of Belarus for participation in the
of electronic microwave
devices.
international Olympiad in Informatics.
A. Tolstsikau, senior lecturer at Department of computational mathA. Tolstsikau,
senior
lecturer
at Department
of computational
ematics,
Belarusian
State
University.
Member
of the jurymathematics,
of the final
State Olympiad
University. Member
of the jury of
the various
final stagestudent
of National
stage Belarusian
of National
in Informatics
and
proOlympiad in Informatics and various student programming contests.
gramming contests. Research interests include parallel and distributed
Research interests include parallel and distributed computing, computational
computing,
computational complexity theory and algorithms and syscomplexity theory and algorithms and systems processing large volumes of
tems processing
information. large volumes of information.

About Journal and Instructions to Authors


OLYMPIADS IN INFORMATICS is a peer-reviewed scholarly journal that provides
an international forum for presenting research and developments in the specific scope
of teaching and learning informatics through olympiads and other competitions. The
journal is focused on the research and practice of professionals who are working in the
field of teaching informatics to talented student. OLYMPIADS IN INFORMATICS is
published annually (in the summer).
The journal consists of two sections: the main part is devoted to research papers
and only original high-quality scientific papers are accepted; the second section is for
countries reports on national olympiads or contests, book reviews, comments on tasks
solutions and other initiatives in connection with teaching informatics in schools.
The journal is closely connected to the scientific conference annually organized during the International Olympiad in Informatics (IOI).
Abstracting/Indexing
OLYMPIADS IN INFORMATICS is abstracted/indexed by:
Cabell Publishing
Central and Eastern European Online Library (CEEOL)
EBSCO
Educational Research Abstracts (ERA)
ERIC
INSPEC
SCOPUS Elsevier Bibliographic Databases
Submission of Manuscripts
All research papers submitted for publication in this journal must contain original unpublished work and must not have been submitted for publication elsewhere. Any manuscript which does not conform to the requirements will be returned.
The journal language is English. No formal limit is placed on the length of a paper,
but the editors may recommend the shortening of a long paper.
Each paper submitted for the journal should be prepared according to the following
structure:
concise and informative title
full names and affiliations of all authors, including e-mail addresses
informative abstract of 70150 words

list of relevant keywords


full text of the paper
list of references
biographic information about the author(s) including photography
All illustrations should be numbered consecutively and supplied with captions. They
must fit on a 124 194 mm sheet of paper, including the title.
The references cited in the text should be indicated in brackets:
for one author (Johnson, 1999)
for two authors (Johnson and Peterson, 2002)
for three or more authors (Johnson et al., 2002)
the page number can be indicated as (Hubwieser, 2001, p. 25)
The list of references should be presented at the end of the paper in alphabetic order.
Papers by the same author(s) in the same year should be distinguished by the letters a, b,
etc. Only Latin characters should be used in references.
Please adhere closely to the following format in the list of references:
For books:
Hubwieser, P. (2001).Didaktik der Informatik. Springer-Verlag, Berlin.
Schwartz, J.E., Beichner, R.J. (1999).Essentials of Educational Technology. Allyn
and Bacon, Boston.
For contribution to collective works:
Batissta, M.T., Clements, D.H. (2000). Mathematics curriculum development as a
scientific endeavor. In: Kelly, A.E., Lesh, R.A. (Eds.),Handbook of Research Design in Mathematics and Science Education. Lawrence Erlbaum Associates Pub.,
London, 737760.
Plomp, T., Reinen, I.J. (1996). Computer literacy. In: Plomp, T., Ely, A.D. (Eds.), International Encyclopedia for Educational Technology. Pergamon Press, London,
626630.
For journal papers:
McCormick, R. (1992). Curriculum development and new information technology.Journal of Information Technology for Teacher Education, 1(1), 2349.
http://rice.edn.deakin.edu.au/archives/JITTE/j113.htm
Burton, B.A. (2010). Encouraging algorithmic thinking without a computer. Olympiads in Informatics, 4, 314.
For documents on Internet:
International Olympiads in Informatics(2008).
http://www.IOInformatics.org/
Hassinen, P., Elomaa, J., Ronkko, J., Halme, J., Hodju, P. (1999). Neural Networks
Tool Nenet (Version 1.1).
http://koti.mbnet.fi/~phodju/nenet/Nenet/General.html

Authors must submit electronic versions of manuscripts in PDF to the editors. The
manuscripts should conform all the requirements above.
If a paper is accepted for publication, the authors will be asked for a computerprocessed text of the final version of the paper, supplemented with illustrations and tables,
prepared as a Microsoft Word or LaTeX document. The illustrations are to be presented
in TIF, WMF, BMP, PCX or PNG formats (the resolution of point graphics pictures is
300 dots per inch).
Contacts for communication
Valentina Dagien
Vilnius University Institute of Mathematics and Informatics
Akademijos str. 4, LT-08663 Vilnius, Lithuania
Phone: +370 5 2109 732
Fax: +370 52 729 209
E-mail: valentina.dagiene@mii.vu.lt
Internet Address
All the information about the journal can be found at:
http://ioinformatics.org/oi_index.shtml

Publisher office: Vilnius University Institute of Mathematics and Informatics


Akademijos str. 4, LT-08663 Vilnius, Lithuania
July, 2016

Olympiads
in Informatics

Olympiads
Olympiads
in
Informatics
in Informatics
Volume 10,
2016
Volume
10,
2016

J. ALEMANY FLOS, J. VILELLA VILAHUR


eSeeCode: Creating a Computer Language from Teaching Experiences

3
19

S. COMBFIS, G. BERESNEVIIUS, V. DAGIEN. Learning Programming through Games


and Contests: Overview, Characterisation and Discussion

39

. ERDSN NMETH, L. ZSAK


The Place of the Dynamic Programming Concept in the Progression of Contestants Thinking

61

S. GRTTER, D. GRAF, B. SCHMID


Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics

73

J.I. GUNAWAN. Understanding Unsolvable Problem

87

J. HROMKOVI. Homo Informaticus Why Computer Science Fundamentals are an Unavoidable Part of Human Culture and How to Teach Them

99
111

M. KABTOV, I. KALA, M. TOMCSNYIOV. Programming in Slovak Primary Schools

125

E. KALINICENKO, M. OPMANIS. Collecting, Processing and Maintaining IOI Statistics

161

A. KARCZMARZ, J. CKI, A. POLAK, J. RADOSZEWSKI, J.O. WOJTASZCZYK


Distributed Tasks: Introducing Distributed Computing to Programming Competitions

177

M.M.I. LIEM. Reshaping Indonesian Students Training for IOI

195

W. Di LUIGI, G. FARINA, L. LAURA, U. NANNI, M. TEMPERINI, L. VERSARI


oii-web: an Interactive Online Programming Contest Training System

207

W. van der VEGT.


Bridging the Gap Between Bebras and Olympiad; Experiences from the Netherlands

223

T. VERHOEFF. Problem Solving, Presenting, and Programming: A Matter of Giving and Taking

231

REPORTS
M. DOLINSKY. Gomel Training School for Olympiads in Informatics

237

V. DUMANYAN, A. ANDREASYAN.
Armenia: IOI Participation and National Olympiads in Informatics

249

A. GREMALSCHI, A. PRISACARU, S. CORLAT.


Olympiads in Informatics in Republic of Moldova

255

A. IGLIKOV, M. KUTYBAYEV, B. MATKARIMOV. IOI 2015 Report

263

A. KHUDER, D. TSEDEVSUREN. The Informatics Olympiad in Mongolia: Training Resources for non-English Speaking Students

279

I. KIRYNOVICH, A. TOLSTSIKAU. Belarusian Olympiad in Informatics

285

ISSN 1822-7732

ISSN 1822-7732

Volume 10, 2016

J. HROMKOVI, T. KOHN, D. KOMM, G. SERAFINI


Examples of Algorithmic Thinking in Programming Education

Olympiads in Informatics

R. CASTRO, N. LEHMANN, J. PREZ, B. SUBERCASEAUX


Wavelet Trees for Competitive Programming

10

IOI

Inter

n at i

nal

Olym

piad

in

Infor

ics
m at

You might also like