300820: CF157A. Game Outcome

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Game Outcome

题意翻译

## 题意 福尔摩斯和华生在一个n * n的棋盘上玩添数游戏。在游戏期间,他们放置一些数到棋盘上,(其中的规则我们不知道)。然而,现在游戏结束了,棋盘中都有一个数字。要知道谁赢,他们需要计算获胜方块的数量。如果要确定特定的方块是否获胜,你需要做到以下几点。分别计算出这个方块所在的纵列上所有数的和(包括自身)和计算出这个方块所在的横列上所有数的和(包括自身)。如果纵列的和大于横列的和,那么这个方块就算一个获胜方块。 如图所示,真是一个结束的棋局。 然后,紫色格子获胜,因为其纵列之和(8+3+6+7=24)大于其横列(9+5+3+2=19)之和,以及24>1924>1924>19。 ## 输入格式 第一行包含一个整数n(1<=n<=30)。 接下来n行,每行n个数,每个数用空格隔开。第i行上的第j个数字表示棋盘上地i行第j列方格上的数字。棋盘上所有数字大于等于1,小于等于100。 ## 输出格式 输出一个数字——获胜方块的数量。

题目描述

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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF157A/8e82a62fc40e8c85c587df26e27e37875a9c9b9b.png)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&gt;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 $ .

输出格式


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<br></br><span class="tex-font-style-bf"><span class="tex-font-style-it"> $ 9 $ $ 5 $ $ 3 $ </span></span> 2<br></br><span class="tex-font-style-bf"><span class="tex-font-style-it"> $ 1 $ $ 6 $ $ 6 $ </span></span> 4<br></br>9 5 7 3<br></br>`

Input

题意翻译

## 题意 福尔摩斯和华生在一个n * n的棋盘上玩添数游戏。在游戏期间,他们放置一些数到棋盘上,(其中的规则我们不知道)。然而,现在游戏结束了,棋盘中都有一个数字。要知道谁赢,他们需要计算获胜方块的数量。如果要确定特定的方块是否获胜,你需要做到以下几点。分别计算出这个方块所在的纵列上所有数的和(包括自身)和计算出这个方块所在的横列上所有数的和(包括自身)。如果纵列的和大于横列的和,那么这个方块就算一个获胜方块。 如图所示,真是一个结束的棋局。 然后,紫色格子获胜,因为其纵列之和(8+3+6+7=24)大于其横列(9+5+3+2=19)之和,以及24>1924>1924>19。 ## 输入格式 第一行包含一个整数n(1<=n<=30)。 接下来n行,每行n个数,每个数用空格隔开。第i行上的第j个数字表示棋盘上地i行第j列方格上的数字。棋盘上所有数字大于等于1,小于等于100。 ## 输出格式 输出一个数字——获胜方块的数量。

加入题单

算法标签: