CF157A.Game Outcome

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number of winning squares. To determine if the particular square is winning you should do the following. Calculate the sum of all numbers on the squares that share this column (including the given square) and separately calculate the sum of all numbers on the squares that share this row (including the given square). A square is considered winning if the sum of the column numbers is strictly greater than the sum of the row numbers.

For instance, lets game was ended like is shown in the picture. Then the purple cell is winning, because the sum of its column numbers equals 8 + 3 + 6 + 7 = 24, sum of its row numbers equals 9 + 5 + 3 + 2 = 19, and 24 > 19.

夏洛克·福尔摩斯与华生博士曾在一块 n×nn \times n 的方格棋盘上进行某场游戏。游戏过程中,他们依据某些我们尚不清楚的巧妙规则在棋盘的方格中填入数字。如今游戏已结束,棋盘上的每个方格中恰好填有一个数字。为了判断谁获胜,他们需要统计“获胜方格”的数量。要判断某个特定方格是否为获胜方格,请执行以下操作:计算该方格所在列(包括该方格自身)中所有数字之和;再单独计算该方格所在行(包括该方格自身)中所有数字之和。若该列数字之和严格大于该行数字之和,则该方格为获胜方格。

例如,假设游戏结束后的棋盘状态如图所示。则紫色方格为获胜方格,因为其所在列的数字之和为 8+3+6+7=248 + 3 + 6 + 7 = 24,其所在行的数字之和为 9+5+3+2=199 + 5 + 3 + 2 = 19,且 24>1924 > 19。

输入格式

The first line contains an integer n (1 ≤ n ≤ 30). Each of the following n lines contain n space-separated integers. The j-th number on the i-th line represents the number on the square that belongs to the j-th column and the i-th row on the board. All number on the board are integers from 1 to 100.

第一行包含一个整数 nn(1≤n≤301 \leq n \leq 30)。接下来的 nn 行,每行包含 nn 个以空格分隔的整数。第 ii 行的第 jj 个数表示棋盘上第 ii 行、第 jj 列方格中的数字。棋盘上的所有数字均为 11 到 100100 之间的整数。

输出格式

Print the single number — the number of the winning squares.

输出一个数字——获胜方格的数量。

输入输出样例

  • 输入#1

    1
    1

    输出#1

    0
  • 输入#2

    2
    1 2
    3 4

    输出#2

    2
  • 输入#3

    4
    5 7 8 4
    9 5 3 2
    1 6 6 4
    9 5 7 3

    输出#3

    6

说明/提示

In the first example two upper squares are winning.

In the third example three left squares in the both middle rows are winning:

5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3

在第一个例子中,上方的两个方格是获胜方格。

在第三个例子中,中间两行最左侧的三个方格是获胜方格:

5 7 8 4
9 5 3 2
1 6 6 4
9 5 7 3

输入解题思路,AI测评打分。不知道怎么写?

首页