
Jack and Jill play a game called Hotter, Colder. Jill has a number between
Each of Jack's guesses is a number between
- hotter if this guess is closer to Jill's number than his previous guess
- colder if this guess is farther from Jill's number than his previous guess
- same if this guess is neither closer to nor further from Jill's number than his previous guess.
You are to implement a procedure HC(N) that plays Jack's role. This implementation may repeatedly call Guess(G), with
Example
For example, assume
Call | Returned value | Explanation |
---|---|---|
Guess( |
Same (first call) | |
Guess( |
Hotter | |
Guess( |
Colder | |
Guess( |
Hotter | |
Guess( |
Same |
At this point, Jack knows the answer, and HC should return
Subtask 1 [25 points]
HC(N) must call Guess(G) at most
Subtask 2 [25 points]
HC(N) must call Guess(G) at most
Subtask 3 [25 points]
HC(N) must call Guess(G) at most
Subtask 4 [up to 25 points]
Let
points, if HC(N) calls Guess(G) times or more, points, where is the largest real number, such that and HC(N) calls Guess(G) at most times, points, if HC(N) calls Guess(G) at most times.
There will be at most
Be sure to initialize any variables used by HC every time it is called.
Implementation Details
- Implementation folder:
/home/ioi2010-contestant/hottercolder/
(prototype: hottercolder.zip) - To be implemented by contestant:
hottercolder.c
orhottercolder.cpp
orhottercolder.pas
- Contestant interface:
hottercolder.h
orhottercolder.pas
- Grader interface:
grader.h
orgraderlib.pas
- Sample grader:
grader.c
orgrader.cpp
orgrader.pas
andgraderlib.pas
- Sample grader input:
grader.in.1
grader.in.2
.
Note: The input file contains several lines, each containing and Jill's number. - Expected output for sample grader input: the grader will create files
grader.out.1
grader.out.2
etc.- If the implementation correctly implements Subtask
, one line of output will containOK 1
- If the implementation correctly implements Subtask
, one line of output will containOK 2
- If the implementation correctly implements Subtask
, one line of output will containOK 3
- If the implementation correctly implements Subtask
, one line of output will containOK 4 alpha α
- If the implementation correctly implements Subtask
Comments