Submission #397732

#TimeUsernameProblemLanguageResultExecution timeMemory
397732ly20Rectangles (IOI19_rect)C++17
37 / 100
5057 ms34848 KiB
 #include "rect.h"
#include <bits/stdc++.h>
using namespace std;


const int MAXN = 2512, MAXK = 13;
int n, m;
int tb[MAXN][MAXN];
long long count_rectangles(vector<vector<int> > ts) {
	n = ts.size();
	m = ts[0].size();
	if(n < 3 || m < 3) return 0;
    long long resp = 0;
	for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            tb[i + 1][j + 1] = ts[i][j];
        }
	}
    for(int i = 2; i < n; i++) {
        for(int j = 2; j < m; j++) {
            for(int k = i; k < n; k++) {
                for(int l = j; l < m; l++) {
                    bool ok = true;
                    for(int i2 = i; i2 <= k; i2++) {
                        for(int j2 = j; j2 <= l; j2++) {
                            int vl = tb[i2][j2];
                            if(vl >= tb[i2][j - 1] || vl >= tb[i2][l + 1] || vl >= tb[i - 1][j2] || vl >= tb[k + 1][j2]) {
                                ok = false;
                                break;
                            }
                        }
                        if(!ok) break;
                    }
                    if(ok) resp++;
                }
            }
        }
    }
	return resp;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...