# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364422 | arujbansal | Rectangles (IOI19_rect) | C++17 | 5071 ms | 28396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
using namespace std;
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epock().count())
#define rng_seed(x) mt19937 rng(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
// #define int long long
const int MXN = 1e5 + 1, INF = 1e9 + 5;
bool valid(int r1, int c1, int r2, int c2, vector<vector<int>> &a) {
int N = sz(a), M = sz(a.back());
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]) return false;
if (a[i][j] >= a[i][c1 - 1] || a[i][j] >= a[i][c2 + 1]) return false;
}
}
return true;
}
int64_t count_rectangles(vector<vector<int>> a) {
int64_t ans = 0;
int N = sz(a), M = sz(a.back());
for (int r1 = 1; r1 < N - 1; r1++) {
for (int c1 = 1; c1 < M - 1; c1++) {
for (int r2 = r1; r2 < N - 1; r2++) {
for (int c2 = c1; c2 < M - 1; c2++) {
ans += valid(r1, c1, r2, c2, a);
}
}
}
}
return ans;
}
// void solve() {
// }
// signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// int TC = 1;
// // cin >> TC;
// while (TC--) solve();
// }
Compilation message (stderr)
# | 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... |