HKOI 2005 Training

Post on 28-Jan-2016

28 views 0 download

description

HKOI 2005 Training. New Problem Types: Interactive and Open Test Data. Roadmap. Interactive Tasks Partial Scoring Open Test Data Tasks. The Traditional Problem Type. Read input, write output Input is static It does not change according to your output - PowerPoint PPT Presentation

Transcript of HKOI 2005 Training

Saturday, January 22, 2005

Liu Chi Man

HKOI 2005 Training

New Problem Types:

Interactive and Open Test Data

- 2 - << Previous Next >>|

Roadmap

Interactive Tasks Partial Scoring Open Test Data Tasks

- 3 - << Previous Next >>|

The Traditional Problem Type

Read input, write output Input is static

It does not change according to your output Program’s output is compared with

judge’s output, or another program (judging program) is used to check its correctness

That’s a must, what else can it be?

- 4 - << Previous Next >>|

Interactive Tasks

Input is dynamicSuccessive input items depend on your

previous output items Forced to make output before you can

continue reading from input “Interactive” doesn’t mean the process of

programming is interactive!

- 5 - << Previous Next >>|

Example: Guess-the-number

My lucky number is an integer between 1 to 5, guess it

Each time you make a guess (an integer), I will reply with either one of:Too bigToo smallCorrect

- 6 - << Previous Next >>|

Example: Guess-the-number

You: 1? Me: Too small. You: 2? Me: Too small. You: 4? Me: Too big. You: 5? Me: Too big. You: 3? Me: Correct.

- 7 - << Previous Next >>|

Interactive Tasks

In the judging environment, you are the submitted program

Note that input varies to suit your output How can the judge achieves this effect?

Another program! In fact there is another way to achieve

interactivityA library!

- 8 - << Previous Next >>|

Roadmap

Interactive Tasks Interactivity via Standard I/O Interactivity via Libraries

Partial Scoring Open Test Data Tasks

- 9 - << Previous Next >>|

Interactivity via Standard I/O

Your program reads from standard I/O as in a traditional tasks

However, at some points, your program must stop reading, produce output, and go on to readJust keep on reading may lead to errors

A judging program reads your output and produces suitable input for you

- 10 - << Previous Next >>|

Interactivity via Standard I/O

123

Standard input

Standard output

Submittedprogram

Judgingprogram

Too smallToo smallCorrect

- 11 - << Previous Next >>|

Interactivity via Standard I/O

This type of interactivity first appeared in IOI1995

I/O are much like the traditional way, but pay attention to the order of input and outputWhen to read? When to write? Read the

problem description carefully

- 12 - << Previous Next >>|

Interactivity via Libraries

A library is a collection of subprograms used to develop software (Wikipedia)

To use a library, In Pascal: uses somelib; In C/C++: #include “somelib.h”

The problem description should contain instructions on using the provided libraryBut you should learn it now

- 13 - << Previous Next >>|

Function Declarations

Pascal examples: procedure myproc(x: integer, var c: char); function myfunc(x, y: integer): integer;

C++ examples: void myproc(int x, char &c); (Not in C) int myfunc(int x, int y);

The declaration and meaning of each library functions provided to you will be shown in the problem description

- 14 - << Previous Next >>|

Interactivity via Libraries

Recall the game of Guess-the-number Suppose we are given a library guesslib

with one function:Pascal: function guess(x: integer): integer;C/C++: int guess(int x);

guess takes an integer parameter, your guess, and returns 1 for “Too big”, -1 for “Too small”, 0 for “Correct”

- 15 - << Previous Next >>|

Interactivity via Libraries

The implementations of the library functions will NOT be given to you

Sometimes you are also required to read from standard input or an input file for initial dataAlways read the problem description

carefully For your information, this type of

interactivity first appeared in IOI1996

- 16 - << Previous Next >>|

Hands-on

Guess-the-number Celebrity

- 17 - << Previous Next >>|

Interactive Tasks

We have discussed two methods to achieve interactivity

Those are just I/O stuff, may not be related to the problem itself at all

Interactivity gave rise to three new major classes of contest problemsDetectionTwo-person gamesOnline problems

- 18 - << Previous Next >>|

Roadmap

Interactive TasksDetectionTwo-person GamesOnline Problems

Partial Scoring Open Test Data Tasks

- 19 - << Previous Next >>|

Detection

Uncover facts using a specialized detector

Examples:CelebrityGuess-the-number

Usually the detector can be used for a very limited number of times, otherwise the problem will become easy

- 20 - << Previous Next >>|

Detection: Strategies

Bisection or Binary Search It makes the worst case betterApplication: Guess-the-number

Any other?

- 21 - << Previous Next >>|

Two-person Games

The judging program (or the library) and your program play a two player game

Examples:Tic-tac-toeNim

Your score depends on how well your program plays against the opponent (judge)

- 22 - << Previous Next >>|

Two-person Games

Unfortunately, your opponent is usually optimal, that is, you are destined to lose once you make a single wrong move

Common strategies and techniquesMinimax

Something from Game Theory

Ad-hocSome well-known or easy-to-derive strategiesApplication: Nim

- 23 - << Previous Next >>|

Online Problems

“Online” does not mean “being connected to the Internet”!

A part of the input data is not available until some later time

Usually an online problem has its offline counterpart

- 24 - << Previous Next >>|

Example: Online Sorting

Sort some given integers Some integers may arrive late Initially

We have 7, 4, 2, 5Bubble-sort them: 2, 4, 5, 7

Then 3, 8 arrivesWe have 7, 4, 2, 5, 3, 8Bubble-sort them: 2, 3, 4, 5, 7, 8

- 25 - << Previous Next >>|

Example: Online Sorting

If we use bubble sort, every time some new integers arrive, we need O(N2) time to re-sort the numbers

If we use insertion sort, every time some new integers arrive, we need O(N) time per new integer to re-sort the number

So you can see insertion sort is more “online” than bubble sort

- 26 - << Previous Next >>|

Online Problems

Most of the time an online problem is much harder to solve that its offline counterpart

Examples of online problems:Mobile Phones (IOI2001)Path Maintenance (IOI2003)

- 27 - << Previous Next >>|

Roadmap

Interactive Tasks Partial Scoring Open Test Data Tasks

- 28 - << Previous Next >>|

The Traditional Scoring Method

For a task, there are some test cases If your program passes a certain test

case, marks for that test case will be awarded to you

For each test case, you either get all or nothing

- 29 - << Previous Next >>|

Partial Scoring

For each test case, you may get something between 0% and 100% exclusive

Why partial scoring?The output consists of several partsSub-optimal solutions

The closer to the optimum, the more marks you can get

- 30 - << Previous Next >>|

Partial Scoring

Measurements of optimalityHow close is your answer to the optimal

solutionHow many queries (detections) have been

made before your program produces the correct answer

Sometimes the optimal solution is not even known to the judgeRelative scoring

- 31 - << Previous Next >>|

Relative Scoring

You score depends on how close your answer is to the best known solution

The best known solution may beThe judge’s official solution (which may not

be optimal)The best solution among all submitted

solutions

- 32 - << Previous Next >>|

Examples of Partial Scoring

Example problemGuess-two-numbers: I have two lucky

integers 1 ≤ A < B ≤ 100, guess themYou may ask me questions in the form “Is it

true that A ≤ X ≤ B?”, where X is an integer.Maximum score per test case is 10 marks

Partial scoring 15 marks for each correctly guessed lucky

integer

- 33 - << Previous Next >>|

Examples of Partial Scoring

Partial scoring 2Let a, b be your output integers and A, B be

the correct answerYour score = max(10-|A-a|-|B-b|, 0)

Partial scoring 3 If your answer is wrong, 0 marks; else if number of queries ≤ 10, 10 marks; else If number of queries ≤ 50, 5 marks; else0 marks

- 34 - << Previous Next >>|

Partial Scoring: Gallery

Berry (NOI2003) Zenith Protected Linked Hybrid Zone

(NOI2003)

- 35 - << Previous Next >>|

Roadmap

Interactive Tasks Partial Scoring Open Test Data Tasks

- 36 - << Previous Next >>|

Open Test Data Tasks

Official judging test cases must be kept confidential until the end of the contest

The above rule no longer holds after the introduction of open test data tasks

Given a number of test cases, you should submit, for each test case, an output file

First appeared in IOI2001

- 37 - << Previous Next >>|

Characteristics of OTD Tasks

NP-HardNo fast algorithms have yet been found

Relative scoringYour solution is compared with an optimal

or, more probably, a near-optimal solution Special cases

Some test cases are actually special cases of the problem which is hard in general

- 38 - << Previous Next >>|

Open Test Data Tasks: Strategies

Manually solve the first casesUsually the first few test cases are easy

enough to solve manually Look at all test cases

There may be wicked but trivial test cases Keep the CPU busy

Let your exhaustive search program run in the background

- 39 - << Previous Next >>|

Open Test Data Tasks: Strategies

Make good use of what you haveOS, image editing program, other compilers,

etc. Identify the special cases

Special cases may be easier to deal with Greedy, randomization, heuristics

Relative scoring does not require an optimal solution!

- 40 - << Previous Next >>|

Open Test Data Tasks

Double Crypt (IOI2001) XOR (IOI2002) Reverse (IOI2003) Polygon (IOI2004) Another Game of Tetris (NOI2002) Berry (NOI2003) Graduate (NOI2004)

- 41 - << Previous Next >>|

Last Words

Interactive and open test data tasks are now quite common in IOI and NOI

They may appear in the coming Team Formation Tests

- 42 - << Previous Next >>|

New Problem Types?

ROBOT (IOI2002 proposed task)From the contest report: However, ROBOT

was in the end rejected… we hope this innovative type of task will be accepted in future IOIs to broaden the IOI task repertoire even further.

Multiple Choice Questions (NOI)Much like doing school exams...Question papers and technical terms in

Simplified Chinese…