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<bits/stdc++.h>
#include "rect.h"
using namespace std;
#define x first
#define y second
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vii = vector<vi>;
using pi = pair<int, int>;
using vpi = vector<pi>;
const int MX = 2e5 + 100;
int N, M;
ll count_rectangles(vii a) {
N = (int)a.size();
M = (int)a[0].size();
if (N == 3) {
vi sum(M, 0);
sum[0] = 0;
for (int i = 1; i < M - 1; ++i)
{
sum[i] = sum[i - 1] + int(a[1][i] < a[0][i] and a[1][i] < a[2][i]);
}
ll ats = 0;
int did = 0;
vi sk = a[1];
for (int s = 0; s < M - 2; ++s)
{
did = sk[s + 1];
for (int f = s + 2; sk[s] > did and f < M; ++f)
{
if (sk[f] > did and sum[f - 1] - sum[s] == f - s - 1) ats++;
did = max(did, sk[f]);
}
}
return ats;
}
return 0;
}
# | 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... |