Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ll long long
- #include <bits/stdc++.h>
- using namespace std;
- const int OO = 1e9;
- const double EPS = 1e-9;
- int arr[105][105];
- int pre[105][105];
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int t;
- cin >> t;
- while(t--) {
- int s,b;
- cin >> s >> b;
- for(int i = 1; i <= s; i++) {
- for(int j = 1; j <= s; j++) {
- arr[i][j] = 0;
- }
- }
- for(int bi = 0; bi < b; bi++) {
- int r1,c1,r2,c2;
- cin >> r1 >> c1 >> r2 >> c2;
- for(int r = r1; r <= r2; r++) {
- for(int c = c1; c <= c2; c++) {
- arr[r][c] = 1;
- }
- }
- }
- for(int r = 1; r <= s; r++) {
- int sum = 0;
- for(int c = 1; c <= s; c++) {
- sum += arr[r][c];
- pre[r][c] = sum + pre[r-1][c];
- }
- }
- int ans = 0;
- for(int r1 = 1; r1 <= s; r1++) {
- for(int r2 = r1; r2 <= s; r2++) {
- int sum = 0;
- for(int c = 1; c <= s; c++) {
- int curr = pre[r2][c] - pre[r2][c-1] - pre[r1-1][c] + pre[r1-1][c-1];
- if(curr == 0) {
- sum += r2-r1+1;
- }
- else {
- sum = 0;
- }
- ans = max(ans,sum);
- }
- }
- }
- cout << ans << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement