이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
#define inf ((int)1e9)
using namespace std;
long long count_rectangles(std::vector<std::vector<int> > a) {
vector <vector<int> > next, cnt;
// bi birlerde kendinden bir sonraki sıfırı tutuyoruz
// bir de gene birlerde kendinden sonraki ardışık sıfır sayısını tutuyoruz
int n = a.size(), m = a[0].size();
next = cnt = vector <vector<int> > (n, vector<int>(m));
for(int i = 0; i < n; i++) {
int zero = m;
for(int j = m - 1; j > 0; j--) {
if(a[i][j]) {
next[i][j] = zero;
}
else {
zero = j;
}
}
int before = 0;
for(int j = 0; j < m; j++) {
if(a[i][j]) {
before = j;
}
else {
cnt[i][before]++;
}
}
}
// column column gez
// duvara çarpma edge casesi, 0 alan edge casesi
long long ans = 0;
for(int j = 1; j < m - 1; j++) {
int val = -1, prevdist = 0;
for(int i = 0; i < n; i++) {
if(a[i][j]) {
int dist = next[i][j] - j;
if(prevdist >= val and dist >= val and val != inf and val > 0 and j + val != m) {
ans++;
}
val = -1;
prevdist = dist;
}
else {
if(val == -1) {
val = cnt[i][j - 1];
}
else if(val != cnt[i][j - 1]) val = inf;
}
}
}
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... |