当前位置:网站首页>UVA10827
UVA10827
2022-08-05 04:59:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 200,INF = -1e9;
int m[maxn][maxn], sum[maxn][maxn],n;
int main()
{
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> m[i][j];
m[i + n][j] = m[i][j + n] = m[i + n][j + n] = m[i][j];
}
}
int len = (n << 1) + 1,ans = INF;
for (int i = 1; i < len; i++) {
for (int j = 1; j < len; j++) {
sum[i][j] = m[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
int a = min(i, n);
int b = min(j, n);
for (int k = 0; k <= a; k++) {
for (int l = 0; l <= b; l++) {
if (!k && !l)continue;
ans = max(sum[i][j] - sum[i - k][j] - sum[i][j - l]+ sum[i - k][j - l],ans);
}
}
}
}
cout << ans << endl;
}
return 0;
}
边栏推荐
猜你喜欢

C+ +核心编程

A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?

The production method of the powered small sailboat is simple, the production method of the electric small sailboat

AUTOCAD——标注关联

【学习笔记之菜Dog学C】动态内存管理之经典笔试题

大学物理---质点运动学

数字孪生技术在电力系统中的应用现状

for..in和for..of的区别

一篇博客通关Redis技术栈

Day019 Method overriding and introduction of related classes
随机推荐
for..in和for..of的区别
【cesium】加载并定位 3D Tileset
1007 Climb Stairs (greedy | C thinking)
【无标题】
App rapid development and construction experience: the importance of small programs + custom plug-ins
开发属于自己的node包
Flutter learning 2-dart learning
WPF中DataContext作用
Mysql的redo log详解
Mysql的undo log详解
upload上传图片到腾讯云,如何上传图片
LeetCode:1403. 非递增顺序的最小子序列【贪心】
Machine Learning Overview
ansible各个模块详解
bytebuffer internal structure
flink reads mongodb data source
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
Flutter学习2-dart学习
LAB 信号量实现细节