## CCO '09 P4 - Bottle Caps

View as PDF

Points: 20 (partial)
Time limit: 7.0s
Memory limit: 256M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You have caps and bottles. Each bottle has a unique size and each cap corresponds to a single bottle. Unfortunately, the caps and bottles are so close together in size that it is impossible to compare them visually.

The only comparison that we can make is between a cap and a bottle. We do this by attempting to put the cap on the bottle. From this, we know whether the cap is too small, too large, or just the right size in relation to the bottle.

Match all the caps to their corresponding bottles as quickly as possible by interacting with a library that compares the pieces.

You may make at most queries.

In of the test cases, .
In another of the test cases, .

#### Interactive Instructions

The first line contains the integer .

Afterwards, you must start interaction.

To query, output 0 capid bottleid. You will receive a 1 if the cap is too large for the bottle, 0 if the cap fits the bottle, and -1 if the cap is too small for the bottle.

To report, output 1 capid bottleid. You will not receive anything back from the interactor.

You may interlace reports and queries. Once you have reported times, your solution must exit. Otherwise, your result is undefined. Only queries (type 0) count towards your query limit.

Note: Up to 3s of the time limit may be taken up by the interactor.

#### Sample Interaction

The cap sizes are: . The bottle sizes are: . >>> denotes your output. Do not print this out.

3
>>> 0 1 1
-1
>>> 0 1 2
0
>>> 0 1 3
1
>>> 1 1 2
>>> 0 2 1
-1
>>> 1 3 1
>>> 1 2 3

#### Description of Sample Interaction

There are three caps and three bottles. The first, second and third cap match the second, third, and first bottle, respectively.