#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#pragma warning(disable:4996)
#include<cstdio>
#include<cstdlib>
using std::cin;
using std::cout;
using std::endl;
using std::stringstream;
using std::string;
using std::vector;
using std::list;
using std::pair;
using std::set;
using std::multiset;
using std::map;
using std::multimap;
using std::stack;
using std::queue;
using std::priority_queue;
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int T;
while (cin >> T)
{
while (T--)
{
int n; cin >> n;
vector<vector<bool>>matrix(n, (vector<bool>)n);
cin >> n;
for (int k = 0; k < n; k++)
{
int row1, row2, column1, column2;
cin >> row1 >> column1 >> row2 >> column2;
for (int i = row1 - 1; i <= row2 - 1; i++)
{
for (int j = column1 - 1; j <= column2 - 1; j++)
{
matrix[i][j] = true;
}
}
}
int max = 0;
for (size_t i = 0; i != matrix.size(); i++)
{
for (size_t j = i; j != matrix.size(); j++)
{
vector<bool>line(matrix.size());
for (auto r = i; r <= j; r++)
{
for (size_t c = 0; c != matrix.size(); c++)
{
if (matrix[r][c])
{
line[c] = matrix[r][c];
}
}
}
vector<int>dp(matrix.size());
if (!line[0])
{
dp[0] = 1;
max = std::max(max, (int)(j - i + 1));
}
for (size_t t = 1; t != matrix.size(); t++)
{
if (!line[t] && !line[t - 1])
{
dp[t] = dp[t - 1] + 1;
}
else if (!line[t])
{
dp[t] = 1;
}
max = std::max(max, (int)(j - i + 1)*dp[t]);
}
}
}
cout << max << endl;
}
}
return 0;
}
UVA_10667_Largest Block
最新推荐文章于 2021-08-01 10:16:11 发布