이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2")
using namespace std;
using i32 = int;
//#define int long long
#define len(x) (int)(x.size())
#define inf 1000'000'000'000'000'000LL
#define all(x) x.begin(), x.end()
#define low_bit(x) (x & (-x))
template<typename T>
using vec = vector<T>;
long long count_rectangles(std::vector<std::vector<i32>> a) {
    int n = len(a);
    int m = len(a[0]);
    long long ans = 0;
    for (int i = 1; i < n - 1; i++) {
        for (int j = 1; j < m - 1; j++) {
            if (a[i][j] >= a[i - 1][j]) continue;
            if (a[i][j] >= a[i][j - 1]) continue;
            [&]() {
                vec<bool> good_layers(n, true);
                vec<int> mx(n, 0);
                for (int k = j; k < m - 1; k++) {
                    int mxs = 0;
                    if (a[i][k] >= a[i - 1][k]) break;
                    int del = 1;
                    for (int l = i; l < n - 1; l++) {
                        bool good = true;
                        {
                            int h = k;
                            mx[l] = max(mx[l], (int) a[l][h]);
                            mxs = max(mxs, (int) a[l][h]);
                            if (mxs >= min(a[i - 1][h], a[l + 1][h])) {
                                good = false;
                            }
                        }
                        good_layers[l] = good and good_layers[l];
                        if (mx[l] >= a[l][j - 1]) {
                            return;
                        }
                        if (mx[l] >= min(a[l][j - 1], a[l][k + 1])) {
                            good = false;
                            del = 0;
                            continue;
                        }
                        if (!good_layers[l]) continue;
                        if (!good) continue;
                        good_layers[l] = true;
                        ans += del;
                    }
                }
            }();
        }
    }
    return ans;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |