# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143973 | tincamatei | Rectangles (IOI19_rect) | C++14 | 2 ms | 396 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 "rect.h"
using namespace std;
bool goodRect(int i, int j, int exp) {
return j - i - 1 > 0 && exp >= j - i - 1;
}
long long subtask5(const vector<vector<int> > &matr) {
int N = matr.size(), M = matr[0].size();
int exp = 0;
int top = 0;
long long rez = 0LL;
vector<int> stiva(M);
for(int c = 0; c < M; ++c) {
bool eq = false;
while(top > 0 && matr[1][c] >= matr[1][stiva[top - 1]]) {
rez = rez + goodRect(stiva[top - 1], c, exp);
if(matr[1][c] == matr[1][stiva[top - 1]])
eq = true;
--top;
}
if(!eq && top > 0)
rez = rez + goodRect(stiva[top - 1], c, exp);
stiva[top++] = c;
if(matr[0][c] > matr[1][c] && matr[2][c] > matr[1][c])
++exp;
else
exp = 0;
}
return rez;
}
long long count_rectangles(std::vector<std::vector<int> > a) {
int N;
N = a.size();
if(N == 3)
return subtask5(a);
return 0;
}
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... |