Hidden Rook
Time limit15sMemory limit256 MB
Find the cell of a hidden rook on an n by m board using at most 4 queries that count the cells a rectangle has under attack.
- Level
Medium6 of 10
- Topics
- Binary search, Math
- Solved
- No attempts yet
Problem
Roman hid a rook on an chessboard. Find its exact position.
This problem is interactive. You may ask the following question at most 4 times.
"How many cells with and are under the hidden rook's attack?"
A rook attacks every cell in its row and column, including its own cell.
Input
The first line contains an integer , the number of test cases ().