A1289 | [COCI-2013_2014-contest1]#4 RATAR
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
After Mirko's failed stint as a coach and a passing obsession with Croatian meat delicacies, his weight problems have motivated him to work hard as a farmer. He has moved to a village where his friend Slavko lives. Farmers in the village share a large common plot of land in the shape of a N×N square, divided into N² unit squares. A unit square at coordinates2 (i, j) brings in the income of Aij, which can be negative (for example, if the square has to be maintained but is not cultivated). The farmers always divide the common land into smaller rectangular fields with edges parallel to the common land edges.
Slavko is skeptical of Mirko since his failure as a coach, so he insists that both of them are assigned land with the same total income, but also thet the two plots share exactly one common corner so that the two friends can keep an eye on each other (Slavko knows that Mirko is prone to mischief). The common corner must be the only point where the two plots meet, in order to prevent border-related arguments.
You are given a description of the common land plot. Find the total number of plot pairs that satisfy Slavko's criteria.
Slavko is skeptical of Mirko since his failure as a coach, so he insists that both of them are assigned land with the same total income, but also thet the two plots share exactly one common corner so that the two friends can keep an eye on each other (Slavko knows that Mirko is prone to mischief). The common corner must be the only point where the two plots meet, in order to prevent border-related arguments.
You are given a description of the common land plot. Find the total number of plot pairs that satisfy Slavko's criteria.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 50), the dimensions of the common land plot.
Each of the following N lines contains N space-separated numbers Aij (-1000 < Aij < 1000), the income provided by the respective cell.
Each of the following N lines contains N space-separated numbers Aij (-1000 < Aij < 1000), the income provided by the respective cell.
输出格式
The first and only line of output must contain the totl number of plot pairs satisfying the given condition.
输入输出样例
输入 #1
3 1 2 3 2 3 4 3 4 8
输出 #1
7
输入 #2
4 -1 -1 -1 -1 1 2 3 4 1 2 3 4 1 2 3 4
输出 #2
10
输入 #3
5 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -5 -5 -5 -5 -5
输出 #3
36
In test data worth at least 40% of total points, N will be at most 10.
Clarification of the first example: The possible rectangle pairs are:
(0,0)-(1,1) and (2,2)-(2,2), (1,0)-(1,0) and (0,1)-(0,1), (2,0)-(2,0) and (1,1)-(1,1), (1,1)-(1,1) and (0,2)-(0,2),
(2,1)-(2,1) and (1,2)-(1,2), (2,0)-(2,1) and (0,2)-(1,2), (1,0)-(2,0) and (0,1)-(0,2).
Clarification of the first example: The possible rectangle pairs are:
(0,0)-(1,1) and (2,2)-(2,2), (1,0)-(1,0) and (0,1)-(0,1), (2,0)-(2,0) and (1,1)-(1,1), (1,1)-(1,1) and (0,2)-(0,2),
(2,1)-(2,1) and (1,2)-(1,2), (2,0)-(2,1) and (0,2)-(1,2), (1,0)-(2,0) and (0,1)-(0,2).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted