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"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long count_rectangles(vector<vector<int> > a) {
int n = a.size();
int m = a[0].size();
ll ans = 0;
ll curstreak =0;
for(int i =1; i<n-1 ;i++){
for(int j =1 ;j <m-1; j++){
int cnt = 0;
if(a[i-1][j] < a[i][j])
cnt++;
if(a[i+1][j] < a[i][j])
cnt++;
if(a[i][j-1] < a[i][j])
cnt++;
if(a[i][j+1] < a[i][j])
cnt++;
if(cnt == 4){
curstreak++;
ans+= curstreak * (curstreak + 1)/2;
}
else{
curstreak = 0;
}
}
}
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... |