Submission #971856

#TimeUsernameProblemLanguageResultExecution timeMemory
971856opPORectangles (IOI19_rect)C++14
18 / 100
5076 ms22696 KiB
#include "rect.h" #include <bits/stdc++.h> #define sz(x) (int)x.size() using namespace std; long long count_rectangles(vector<vector<int>> a) { int n = sz(a); int m = sz(a[0]); if (n <= 2 || m <= 2) { return 0; } if (n == 3) { long long res = 0; for (int l = 0; l < m; l++) { int mx = -1e9; for (int r = l + 1; r < m; r++) { if (r - l > 1 && mx < a[1][l] && mx < a[1][r]) { res++; } if (a[1][r] >= a[0][r] || a[1][r] >= a[2][r]) break; mx = max(mx, a[1][r]); } } return res; } long long res = 0; for (int r1 = 1; r1 < n - 1; r1++) { for (int r2 = r1; r2 < n - 1; r2++) { for (int c1 = 1; c1 < m - 1; c1++) { for (int c2 = c1; c2 < m - 1; c2++) { bool ok = 1; for (int i = r1; i <= r2; i++) { for (int j = c1; j <= c2; j++) { if (a[i][j] >= a[r1 - 1][j] || a[i][j] >= a[r2 + 1][j] || a[i][j] >= a[i][c1 - 1] || a[i][j] >= a[i][c2 + 1]) { ok = 0; } } } res += ok; } } } } //assert(res <= 1ll * n * m); return res; } /* g++ -std=gnu++14 -O2 -Wall -pipe -static -o "rect" "grader.cpp" "rect.cpp" */
#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...