A10472 | Animals and Puzzle
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Owl Sonya gave a huge lake puzzle of size $n×m$ to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turned out to be empty — there was no picture on them. Parts with picture on it are denoted by $1$ , while empty parts are denoted by $0$ . Rows of the puzzle are numbered from top to bottom with integers from $1$ to $n$ , while columns are numbered from left to right with integers from $1$ to $m$ .
Animals decided to complete the picture and play with it, as it might be even more fun! Owl and hedgehog ask each other some queries. Each query is provided by four integers $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ which define the rectangle, where $(x_{1},y_{1})$ stands for the coordinates of the up left cell of the rectangle, while $(x_{2},y_{2})$ stands for the coordinates of the bottom right cell. The answer to the query is the size of the maximum square consisting of picture parts only (only parts denoted by $1$ ) and located fully inside the query rectangle.
Help Sonya and Filya answer $t$ queries.
Animals decided to complete the picture and play with it, as it might be even more fun! Owl and hedgehog ask each other some queries. Each query is provided by four integers $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ which define the rectangle, where $(x_{1},y_{1})$ stands for the coordinates of the up left cell of the rectangle, while $(x_{2},y_{2})$ stands for the coordinates of the bottom right cell. The answer to the query is the size of the maximum square consisting of picture parts only (only parts denoted by $1$ ) and located fully inside the query rectangle.
Help Sonya and Filya answer $t$ queries.
输入格式
The first line of the input contains two integers $n$ and $m$ ( $1<=n,m<=1000$ ) — sizes of the puzzle.
Each of the following $n$ lines contains $m$ integers $a_{ij}$ . Each of them is equal to $1$ if the corresponding cell contains a picture and $0$ if it's empty.
Next line contains an integer $t$ ( $1<=t<=1000000$ ) — the number of queries.
Then follow $t$ lines with queries' descriptions. Each of them contains four integers $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ ( $1<=x_{1}<=x_{2}<=n$ , $1<=y_{1}<=y_{2}<=m$ ) — coordinates of the up left and bottom right cells of the query rectangle.
Each of the following $n$ lines contains $m$ integers $a_{ij}$ . Each of them is equal to $1$ if the corresponding cell contains a picture and $0$ if it's empty.
Next line contains an integer $t$ ( $1<=t<=1000000$ ) — the number of queries.
Then follow $t$ lines with queries' descriptions. Each of them contains four integers $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ ( $1<=x_{1}<=x_{2}<=n$ , $1<=y_{1}<=y_{2}<=m$ ) — coordinates of the up left and bottom right cells of the query rectangle.
输出格式
Print $t$ lines. The $i$ -th of them should contain the maximum size of the square consisting of $1$ -s and lying fully inside the query rectangle.
输入输出样例
输入 #1
3 4 1 1 0 1 0 1 1 0 0 1 1 0 5 1 1 2 3 2 1 3 2 3 2 3 4 1 1 3 4 1 2 3 4
输出 #1
1 1 1 2 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted