이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I can do all things through Christ who strengthens me
// Philippians 4:13
#include "rect.h"
#include "bits/stdc++.h"
using namespace std;
#define REP(i, j, k) for (int i = j; i < (k); i++)
#define RREP(i, j, k) for (int i = j; i >= (k); i--)
template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define SZ(x) (int) x.size()
#define ALL(x) x.begin(), x.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005;
const int MAXN = 705;
int n, m;
vector<vi> a;
bool gdc[MAXN][MAXN][MAXN], gdr[MAXN][MAXN][MAXN];
ll ans;
ll count_rectangles(vector<vi> _a) {
a = _a;
n = SZ(a), m = SZ(a[0]);
REP (i, 1, n - 1) {
REP (j, 1, m - 1) {
int mx = -1;
REP (k, i, n - 1) {
mxto(mx, a[k][j]);
gdc[i][j][k] = mx < min(a[i - 1][j], a[k + 1][j]);
}
}
}
REP (i, 1, n - 1) {
REP (j, 1, m - 1) {
int mx = -1;
REP (k, j, m - 1) {
mxto(mx, a[i][k]);
gdr[i][j][k] = mx < min(a[i][j - 1], a[i][k + 1]);
}
}
}
REP (i, 1, n - 1) {
REP (j, 1, m - 1) {
REP (k, i, n - 1) {
REP (l, j, m - 1) {
if (!gdc[i][l][k]) {
continue;
}
bool pos = 1;
REP (p, i, k + 1) {
if (!gdr[p][j][l]) {
pos = 0;
break;
}
}
ans += pos;
}
}
}
}
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... |