This is a function-based interactive problem.
There is a hidden grid. Each cell either contains one block or is empty. You cannot see the hidden grid directly.
You may use the following two types of lasers.
Each laser has an integer strength . A laser of strength penetrates the first blocks it meets in its direction, and stops at the next block. If there are at most blocks in its direction, the laser exits the grid.
You may perform at most experiments. In one experiment, you choose the strengths of all row lasers and all column lasers, and fire them simultaneously. After the experiment, you receive the stopping position of each laser, or the information that it exited the grid.
Using only the results of these experiments, find the total number of blocks in the entire grid.
Implementation details
You must include the following header file.
#include "plast.h"
You must implement the following function.
int count_blocks(int n);
Do not implement the main function. The grader provides the main function.
The function count\_blocks receives the grid size . It may call the function experiment at most times, and must return the total number of blocks in the grid.
The following function is provided by the grader.
std::vector<int> experiment(
const std::vector<int>& row_strength,
const std::vector<int>& col_strength
);
Both row\_strength and col\_strength must have length .
This is a function-based interactive problem, so the contestant program must not read from standard input directly.
The grader passes the size of the hidden grid as the argument of count\_blocks(n).
The contestant program must not print the answer to standard output directly.
The function count\_blocks(n) must return the total number of blocks in the grid.
experiment may be called at most times.row\_strength[i] is the strength of the laser fired from left to right in row .col\_strength[j] is the strength of the laser fired from top to bottom in column .Every strength must be an integer between and , inclusive.
The function experiment returns a vector of length .
Calling experiment more than times, passing vectors of invalid lengths, or passing strengths outside the allowed range results in Wrong Answer.