CF255D.Mr. Bender and Square
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right from 1 to n. Initially there is exactly one switched on cell with coordinates (x, y) (x is the row number, y is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on.
For a cell with coordinates (x, y) the side-adjacent cells are cells with coordinates (x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1).
In how many seconds will Mr. Bender get happy?
本德先生有一块大小为 n×n 的数字表格,每个格子可以开启或关闭。他希望表格中至少有 c 个开启的格子;当这一条件满足时,本德先生就会感到开心。
我们将表格的行从上到下编号为 1 到 n,列从左到右编号为 1 到 n。初始时刻,恰好有一个格子处于开启状态,其坐标为 (x,y)(其中 x 为行号,y 为列号),其余所有格子均处于关闭状态。此后,每一秒,我们都会将所有当前处于关闭状态、但具有边相邻(即共享一条边)的开启格子的格子开启。
对于坐标为 (x,y) 的格子,其边相邻格子的坐标分别为 (x−1,y)、(x+1,y)、(x,y−1) 和 (x,y+1)。
请问:本德先生需要多少秒才会开心?
输入格式
The first line contains four space-separated integers n, x, y, c (1 ≤ n, c ≤ 109; 1 ≤ x, y ≤ n; c ≤ _n_2).
第一行包含四个以空格分隔的整数 n、x、y、c(1 ≤ n, c ≤ 109;1 ≤ x, y ≤ n;c ≤ n2)。
输出格式
In a single line print a single integer — the answer to the problem.
在一行中输出一个整数——该问题的答案。
输入输出样例
输入#1
6 4 3 1
输出#1
0
输入#2
9 3 8 10
输出#2
2
说明/提示
Initially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure.
.
最初,第一次测试中只有一个被涂色的单元格,因此答案为 0。在第二次测试中,所有事件的发生过程如图所示。

输入解题思路,AI测评打分。不知道怎么写?