A11142 | Binary Blocks
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an image, that can be represented with a $2$ -d $n$ by $m$ grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer $k>1$ and split the image into $k$ by $k$ blocks. If $n$ and $m$ are not divisible by $k$ , the image is padded with only zeros on the right and bottom so that they are divisible by $k$ . Each pixel in each individual block must have the same value. The given image may not be compressible in its current state. Find the minimum number of pixels you need to toggle (after padding) in order for the image to be compressible for some $k$ . More specifically, the steps are to first choose $k$ , then the image is padded with zeros, then, we can toggle the pixels so it is compressible for this $k$ . The image must be compressible in that state.
输入格式
The first line of input will contain two integers $n,m$ ( $2<=n,m<=2500$ ), the dimensions of the image.
The next $n$ lines of input will contain a binary string with exactly $m$ characters, representing the image.
The next $n$ lines of input will contain a binary string with exactly $m$ characters, representing the image.
输出格式
Print a single integer, the minimum number of pixels needed to toggle to make the image compressible.
输入输出样例
输入 #1
3 5 00100 10110 11001
输出 #1
5
We first choose $k=2$ .
The image is padded as follows:
The image is padded as follows:
<br></br>001000<br></br>101100<br></br>110010<br></br>000000<br></br>We can toggle the image to look as follows:<br></br>001100<br></br>001100<br></br>000000<br></br>000000<br></br>We can see that this image is compressible for $k=2$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted