이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
vector<bitset<700>> root;
struct tree{
vector<bitset<700>> seg;
void init(int n){
seg.resize(4*n+5);
for(auto &u : seg)
u.flip();
}
void upd(int v, int tl, int tr, int idx, bitset<700> &val){
if(tl == idx && tr == idx){
seg[v] = val;
return;
}
if(idx <= (tl+tr)/2)
upd(2*v, tl, (tl+tr)/2, idx, val);
else
upd(2*v+1, (tl+tr)/2+1, tr, idx, val);
seg[v] = seg[2*v]&seg[2*v+1];
}
int get(int v, int tl, int tr, int val){
if(tl == tr) return tl;
if(seg[2*v][val] == 0)
return get(2*v, tl, (tl+tr)/2, val);
return get(2*v+1, (tl+tr)/2+1, tr, val);
}
};
bitset<100> lef[100][100];
bitset<100> down[100][100];
bitset<100> lefr[100][100][100];
bitset<100> downr[100][100][100];
int n, m;
long long count_rectangles(vector<std::vector<int> > a) {
n = a.size();
m = a[0].size();
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j){
int maxi = 0;
for(int k = j+1; k < m; ++k){
if(a[i][j] <= maxi) break;
lef[i][j][k] = a[i][k] > maxi;
maxi = max(maxi, a[i][k]);
}
}
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j){
int maxi = 0;
for(int k = i+1; k < n; ++k){
if(a[i][j] <= maxi) break;
down[i][j][k] = a[k][j] > maxi;
maxi = max(maxi, a[k][j]);
}
}
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
for(int k = j; k < m; ++k){
if(j == k)
downr[i][j][k] = down[i][j];
else
downr[i][j][k] = (down[i][j]&downr[i][j][k-1]);
}
for(int i = 0; i < m; ++i)
for(int j = 0; j < n; ++j)
for(int k = j; k < n; ++k){
if(j == k)
lefr[i][j][k] = lef[j][i];
else
lefr[i][j][k] = (lef[j][i]&lefr[i][j][k-1]);
}
ll ans = 0;
for(int i1 = 1; i1 < n-1; ++i1)
for(int i2 = i1; i2 < n-1; ++i2)
for(int j1 = 1; j1 < m-1; ++j1)
for(int j2 = j1; j2 < m-1; ++j2){
ans += downr[i1-1][j1][j2][i2+1]&lefr[j1-1][i1][i2][j2+1];
}
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... |