이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++){
int leftind = 0;
for(int j =1 ;j <m-1; j++){
int cnt = 0;
//cout << a[i][j]<<", "<<leftind<< ": "<<a[i][leftind]<<endl;
bool pos = true;
if(a[i][leftind] <= a[i][j]){
leftind = j -1;
pos = false;
}
if(a[i-1][j] > a[i][j])
cnt++;
else
pos = false;
if(a[i+1][j] > a[i][j])
cnt++;
else
pos = false;
if(a[i][leftind] > a[i][j])
cnt++;
if(a[i][j+1] > a[i][j])
cnt++;
if(pos)
curstreak++;
else
curstreak = 0;
//cout << pos<<": "<<curstreak<<endl;
if(cnt == 4){
ans+= curstreak * (curstreak + 1)/2;
}
}
}
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... |