CF126C.E-reader Display
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
经过多年的努力,科学家们发明了一种全新的电子阅读器显示屏。这种新型显示屏具有更高的分辨率、更低的能耗,且生产成本更低。此外,它还可以弯曲。唯一的不便之处在于其高度特殊的控制方式。正因如此,开发人员决定将电子阅读器的软件交由程序员来实现。
该显示屏由一个 n×n 的像素方阵构成,每个像素只能是黑色或白色。显示屏的行从上到下依次编号为 1 至 n,列从左到右依次编号为 1 至 n。显示屏可执行形如 “x,y” 的指令。在传统显示屏上,执行该指令仅会翻转坐标为 (x,y) 的像素(其中 x 为行号,y 为列号)的颜色;但在我们的新型显示屏上,所有位于以下两个线段之一上的像素(含两个端点)的颜色均会被翻转:线段 (x,x) 到 (x,y),以及线段 (y,y) 到 (x,y)。
例如,若初始时一个 5×5 的显示屏全为白色,则依次执行指令 (1,4)、(3,5)、(5,1)、(3,3) 将导致如下变化:

你是一名电子阅读器软件程序员,需要计算出显示目标图像所需的最少指令数。你可以假设显示屏所有像素初始均为白色。
输入格式
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.
第一行包含一个数字 n(1≤n≤2000)。
接下来的 n 行,每行包含 n 个字符:表示需要显示的图像。字符 "0" 表示白色,"1" 表示黑色。
输出格式
Print one integer z — the least number of commands needed to display the picture.
输出一个整数 z —— 显示该图片所需的最少命令数。
输入输出样例
输入#1
5 01110 10010 10001 10011 11110
输出#1
4
输入解题思路,AI测评打分。不知道怎么写?