You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include<bits/stdc++.h> //万能头文件
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int n;
|
|
|
|
|
cin >> n;
|
|
|
|
|
int a[n][n], sum[1000 * 1000] = {0}; //sum用来记录矩阵每一个容身之处的分数
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < n; j++) {
|
|
|
|
|
cin >> a[i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int aa = 0; //因为不知道一共有多少个sum,所以用aa计数
|
|
|
|
|
for (int i = 0; i < n; i++) { //在矩阵中找无敌人的地点
|
|
|
|
|
for (int j = 0; j < n; j++) {
|
|
|
|
|
if (a[i][j] == 0) {
|
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
|
sum[aa] += a[k][j]; //统计所在列获得的分数
|
|
|
|
|
}
|
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
|
sum[aa] += a[i][k]; //统计所在行获得的分数
|
|
|
|
|
}
|
|
|
|
|
aa++; //统计完一个点的分数后使用数组的下一位进行存储
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} //sort真好用
|
|
|
|
|
sort(sum, sum + n * n, greater<int>()); //把每个点获得的分数从大到小排序
|
|
|
|
|
cout << sum[0] << endl; //输出最大分数
|
|
|
|
|
return 0;
|
|
|
|
|
}
|