A8325 | E-reader Display
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decided to leave the e-readers' software to programmers.
The display is represented by $n×n$ square of pixels, each of which can be either black or white. The display rows are numbered with integers from $1$ to $n$ upside down, the columns are numbered with integers from $1$ to $n$ from the left to the right. The display can perform commands like " $x,y$ ". When a traditional display fulfills such command, it simply inverts a color of $(x,y)$ , where $x$ is the row number and $y$ is the column number. But in our new display every pixel that belongs to at least one of the segments $(x,x)-(x,y)$ and $(y,y)-(x,y)$ (both ends of both segments are included) inverts a color.
For example, if initially a display $5×5$ in size is absolutely white, then the sequence of commands $(1,4)$ , $(3,5)$ , $(5,1)$ , $(3,3)$ leads to the following changes:
You are an e-reader software programmer and you should calculate minimal number of commands needed to display the picture. You can regard all display pixels as initially white.
The display is represented by $n×n$ square of pixels, each of which can be either black or white. The display rows are numbered with integers from $1$ to $n$ upside down, the columns are numbered with integers from $1$ to $n$ from the left to the right. The display can perform commands like " $x,y$ ". When a traditional display fulfills such command, it simply inverts a color of $(x,y)$ , where $x$ is the row number and $y$ is the column number. But in our new display every pixel that belongs to at least one of the segments $(x,x)-(x,y)$ and $(y,y)-(x,y)$ (both ends of both segments are included) inverts a color.
For example, if initially a display $5×5$ in size is absolutely white, then the sequence of commands $(1,4)$ , $(3,5)$ , $(5,1)$ , $(3,3)$ leads to the following changes:
You are an e-reader software programmer and you should calculate minimal number of commands needed to display the picture. You can regard all display pixels as initially white.
输入格式
The first line contains number $n$ ( $1<=n<=2000$ ).
Next $n$ lines contain $n$ characters each: the description of the picture that needs to be shown. "0" represents the white color and "1" represents the black color.
Next $n$ lines contain $n$ characters each: the description of the picture that needs to be shown. "0" represents the white color and "1" represents the black color.
输出格式
Print one integer $z$ — the least number of commands needed to display the picture.
输入输出样例
输入 #1
5 01110 10010 10001 10011 11110
输出 #1
4
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted