#include "rect.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;
constexpr short LOG = 12;
constexpr short smal = -1e4;
struct tavola_sparsa{
vector<vector<short>> sp;
tavola_sparsa(vector<short> &v){
short n = v.size();
sp.resize(LOG, vector<short>(n));
sp[0] = v;
for(int i=1; i<LOG; i++){
for(int j=0; j<=(n - (1<<i)); j++){
sp[i][j] = max(sp[i-1][j], sp[i-1][j + (1 << (i-1))]);
}
}
}
tavola_sparsa() {}
short query(short l, short r){
short log = 31 - __builtin_clz(r-l);
return max(sp[log][l], sp[log][r-(1<<log)]);
}
};
struct segment2d{
vector<tavola_sparsa> tr;
int sz;
segment2d(vector<vector<short>> &v){
sz = 1;
while(sz < v.size()) sz *= 2;
tr.resize(2*sz);
int sz2 = v[0].size();
vector<short> ilvuoto(sz2);
vector<short> treesus(sz2);
for(int i=0; i<v.size(); i++) tr[i+sz] = tavola_sparsa(v[i]);
for(int i=v.size(); i<sz; i++) tr[i+sz] = tavola_sparsa(ilvuoto);
for(int i=sz; --i;){
for(int j=0; j<sz2; j++) treesus[j] = max(tr[2*i].query(j, j+1), tr[2*i+1].query(j, j+1));
tr[i] = tavola_sparsa(treesus);
}
}
int query(int l, int r, int ql, int qr){
short ans = smal;
for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
if(l & 1) ans = max(ans, tr[l++].query(ql, qr));
if(r & 1) ans = max(ans, tr[--r].query(ql, qr));
}
return ans;
}
};
long long count_rectangles(vector<vector<int>> a) {
int n = a.size();
int m = a[0].size();
vector up(n, vector<short>(m, -1)), down(n, vector<short>(m, n)), left(n, vector<short>(m, -1)), right(n, vector<short>(m, m));
//right
for(int i=0; i<n; i++){
stack<int> s;
for(int j=0; j<m; j++){
while(s.size() and a[i][s.top()] < a[i][j]){
right[i][s.top()] = j;
s.pop();
}
s.push(j);
}
}
//left
for(int i=0; i<n; i++){
stack<int> s;
for(int j=m-1; j>=0; j--){
while(s.size() and a[i][s.top()] < a[i][j]){
left[i][s.top()] = j;
s.pop();
}
s.push(j);
}
}
//up
for(int j=0; j<m; j++){
stack<int> s;
for(int i=n-1; i>=0; i--){
while(s.size() and a[s.top()][j] < a[i][j]){
up[s.top()][j] = i;
s.pop();
}
s.push(i);
}
}
//down
for(int j=0; j<m; j++){
stack<int> s;
for(int i=0; i<n; i++){
while(s.size() and a[s.top()][j] < a[i][j]){
down[s.top()][j] = i;
s.pop();
}
s.push(i);
}
}
int ans = 0;
vector querysus(n, vector<bool>(m, true));
segment2d lesegment(right);
for(int i=1; i<n-1; i++){
for(int j=1; j<m-1; j++){
int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
if(l == -1 or r == m or u == -1 or d == n){
querysus[i][j] = 0;
continue;
}
if(querysus[i][j] and r != lesegment.query(u+1, d, l+1, r)) querysus[i][j] = 0;
}
}
lesegment.~segment2d();
new (&lesegment)segment2d(down);
for(int i=1; i<n-1; i++){
for(int j=1; j<m-1; j++){
int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
if(querysus[i][j] and d != lesegment.query(u+1, d, l+1, r)) querysus[i][j] = 0;
}
}
vector somethingsus(n, vector<short>(m));
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
somethingsus[i][j] = -left[i][j];
}
}
lesegment.~segment2d();
new (&lesegment)segment2d(somethingsus);
for(int i=1; i<n-1; i++){
for(int j=1; j<m-1; j++){
int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
if(querysus[i][j] and l != -lesegment.query(u+1, d, l+1, r)) querysus[i][j] = 0;
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
somethingsus[i][j] = -up[i][j];
}
}
lesegment.~segment2d();
new (&lesegment)segment2d(somethingsus);
for(int i=1; i<n-1; i++){
for(int j=1; j<m-1; j++){
int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
if(querysus[i][j] and u != -lesegment.query(u+1, d, l+1, r)) querysus[i][j] = 0;
}
}
vector<array<int, 4>> grind;
for(int i=1; i<n-1; i++){
for(int j=1; j<m-1; j++){
int l = left[i][j], r = right[i][j], u = up[i][j], d = down[i][j];
if(querysus[i][j]){
grind.push_back({l, r, u, d});
}
}
}
sort(grind.begin(), grind.end());
return unique(grind.begin(), grind.end()) - grind.begin();
}
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡴⡖⣻⡟⣛⡛⣿⣿⣿⣿⣻⣿⣿⡟⠛⠳⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣯⣾⣤⣹⣷⣿⣿⡿⣿⡿⣿⣿⣿⣿⣼⣧⣄⣚⠉⠛⠶⢶⣤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣙⠾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢘⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠿⠛⠛⠛⠛⠿⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣯⡿⠀⠀⠀⠀⠀⠀⠀⠠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⢀⣀⣄⡀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⡇⣠⣾⣿⣿⣶⣶⣶⣶⣿⣦⡀⠀⠻⣤⣶⣾⣿⣿⣿⣿⣿⠿⠿⣿⣶⣄⠈⣿⡇⢹⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⠁⡿⠟⣉⣽⣿⣿⣿⣿⣿⣿⡗⠀⠀⢈⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣦⣹⡇⣽⣿⣿⣿⣿⣿⣿⣿⠀⣀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⠴⠂⠀⣀⣤⣾⣿⣿⣿⣿⣿⡿⠀⢱⣿⣿⣏⣛⣛⣣⢬⣹⢿⠏⠀⢀⣼⣿⣯⡛⠒⢽⣿⣥⡿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣿⣿⣿⣿⣍⣉⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣰⣿⠤⣶⣿⠿⣻⣿⣿⣿⣿⣿⣿⡇⠀⠀⠋⠀⠉⠉⠁⠒⠉⠀⠀⡀⠀⠀⢿⣿⣿⠛⠦⠀⠀⢸⡿⠋⠋⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡛⣆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠉⢡⣰⣥⠾⣿⣿⣿⣿⣿⣿⣿⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡾⠁⠀⠀⢸⡿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣾⣿⣿⣿⣿⡹⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⡕⠽⣾⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣶⣶⣤⣶⣿⣷⣼⣧⡀⠀⠀⠀⠠⠀⢀⣰⣿⣿⣿⣿⣿⣿⣷⣻⣿⣿⣿⣿⣿⣿⢿⣿⣶⠄
⠀⠀⠀⠀⠀⠀⠀⠀⡞⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⢠⠎⠻⠯⣍⠙⠟⢻⣿⠿⣿⠟⠀⠀⠀⣶⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⠳⣌⢣⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣡⠖⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠈⠀⢀⣴⣿⠟⠁⢾⣿⣷⣄⡀⡀⠀⠀⠿⠟⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠈⠁⠀⣧
⠀⠀⠀⠀⠀⠀⠀⣼⠃⠀⠀⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡤⠀⠀⠀⣠⣾⣾⠟⢛⣁⣤⣠⣼⣿⣿⣿⣿⣿⣶⣄⣠⣾⣫⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠙⠷⣦⣾⣿⠟⢿⣿⣿⣿⣿⣿⣿⣿⣿⠘⣷⣱⠀⣼⣿⡯⡿⠾⠛⠛⠛⠛⠛⢻⣿⣿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠋⠀⠀⣻⣿⣿⣿⣿⣿⣿⣿⣷⣿⣷⠃⢿⡟⠀⠀⠰⣦⣤⣤⣴⣶⣿⣿⣿⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⡶⢿⣷⣦⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠈⠀⠀⠀⠀⠀⠛⠉⠛⠛⠛⠻⣿⢟⣉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠘⣼⣌⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⣽⣷⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣷⣶⣠⣤⣠⣦⡡⣠⣼⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠦⣽⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⠉⡆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠟⠛⠉⢿⣿⣿⣿⣿⣿⣿⣿⣿⡾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣟⡿⣻⣿⠟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣤⠴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣟⡛⠁⠘⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣀⣀⣀⣀⣀⣤⢴⣾⠿⣉⣽⠞⠁⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣻⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡿⠒⠾⣿⣭⣌⡉⠉⠙⠳⠟⢁⣐⠛⠃⠀⢐⡶⠉⠉⠻⣿⣿⣿⣿⣯⡙⢿⣯⣉⠉⠻⣿⣿⣏⢿⣿⣿⣿⣿⣿⣬⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣧⢐⡦⣌⠙⢮⡹⠛⢶⣤⣶⣯⣍⢰⠋⠄⠘⠁⠀⠀⠀⠈⠍⠛⠻⢿⣿⣷⣍⡻⣿⣶⣮⣙⠿⢾⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⠆⣈⠵⠶⠈⢺⡉⠙⠿⣿⣿⣿⣷⡷⠂⠀⠀⠀⠰⣾⡄⢀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⢿⣌⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣍⣽⣿⡜⣆⠳⣯⡲⣤⣀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⡌⡄⠀⠀⠀⠀⠙⢶⣄⠀⠙⢿⣿⣟⣀⠀⠀⠀⠀⠈⢿⣾⡇⠀⠀⠀⣮⢙⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⣛⣿⣿⣿⣿⣿⣿⣿⣿⡿⠉⢿⡀⠀⠙⢿⣎⢿⣿⣶⣤⣀⠀⠀⠀
⣿⣿⣷⡹⠀⠀⠀⠀⠀⠀⠈⠻⢦⣄⡙⢻⣿⣾⣤⡀⠀⠀⠈⢿⣿⡀⠀⠀⠹⣾⠟⣿⣿⣿⣿⣿⣿⣿⡏⣿⣿⣿⣿⣿⣿⣿⠿⡛⠑⠀⠂⠸⡿⠝⠀⠄⢻⣧⢻⣆⠉⡹⠿⣿⡂
⣿⣿⣿⣏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢻⣿⣿⣿⣿⣷⣄⣀⠈⣿⣷⣄⠀⠘⠙⠰⢿⣿⣿⣿⣿⣿⣿⣧⣚⣿⣿⣯⡋⠄⠰⢉⡀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣧⢻⣦⠘⡇⠈⠛
⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠈⠉⠙⠛⠛⠻⠾⣿⣿⣟⣷⠀⠀⢪⠙⢿⣿⣿⢿⣿⣿⠙⢻⣿⣿⠁⠶⠔⠈⢑⠋⠀⠀⠀⠀⠀⡀⠀⠀⢿⣿⣧⣙⠦⢻⡀⠀
⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⡆⠀⠘⠷⣷⣧⣽⣾⣯⣿⡗⠸⣿⣿⠀⠠⢰⠚⠊⠀⠂⠀⠀⠀⠀⡌⠈⠒⠘⡿⡁⢹⣶⣾⡇⠀
⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡇⢀⠀⠀⠸⡏⡿⢷⣜⢿⡇⠀⣿⣿⡀⠆⢀⠀⠂⠀⠀⡀⠀⠀⠂⠀⠀⠀⠀⠀⠀⠀⢿⡿⠁⠀
⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣆⠀⠀⠀⠁⠀⠀⠙⣿⡇⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠈⠂⠀⠐⠁⠀⠀⠀⠀⠀⠀⢸⠅⠀⠀
⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⣦⡀⠀⠀⠀⠀⠀⠃⣿⠀⣿⣿⡇⢀⠀⠀⠀⠀⠀⠀⠀⠘⠆⠀⠀⠀⠀⠀⠀⠀⡸⣦⠀⢀
⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡄⠀⣸⣿⡄⠀⡏⠀⢿⢿⡇⠀⠄⠀⠀⠘⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⡄⠀⠀⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⡀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⡀⠀⠀⠙⡽⢣⡜⠐⠹⠆⠁⠀⢺⣿⡇⠀⠀⠀⠀⠀⠀⢡⡂⠐⠀⠂⢤⡀⠈⠀⠀⠀⢀⣿⣿⣿
*/
Compilation message
rect.cpp: In constructor 'segment2d::segment2d(std::vector<std::vector<short int> >&)':
rect.cpp:36:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<short int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | while(sz < v.size()) sz *= 2;
| ~~~^~~~~~~~~~
rect.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<short int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i=0; i<v.size(); i++) tr[i+sz] = tavola_sparsa(v[i]);
| ~^~~~~~~~~
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:117:6: warning: unused variable 'ans' [-Wunused-variable]
117 | int ans = 0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
432 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
432 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
360 KB |
Output is correct |
22 |
Correct |
5 ms |
1372 KB |
Output is correct |
23 |
Correct |
4 ms |
1372 KB |
Output is correct |
24 |
Correct |
3 ms |
1372 KB |
Output is correct |
25 |
Correct |
2 ms |
1116 KB |
Output is correct |
26 |
Correct |
3 ms |
1112 KB |
Output is correct |
27 |
Correct |
3 ms |
1116 KB |
Output is correct |
28 |
Correct |
3 ms |
1116 KB |
Output is correct |
29 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
1372 KB |
Output is correct |
18 |
Correct |
4 ms |
1372 KB |
Output is correct |
19 |
Correct |
3 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1116 KB |
Output is correct |
21 |
Correct |
3 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1116 KB |
Output is correct |
23 |
Correct |
3 ms |
1116 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
0 ms |
432 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
360 KB |
Output is correct |
30 |
Correct |
19 ms |
5076 KB |
Output is correct |
31 |
Correct |
17 ms |
5236 KB |
Output is correct |
32 |
Correct |
18 ms |
5332 KB |
Output is correct |
33 |
Correct |
10 ms |
3932 KB |
Output is correct |
34 |
Correct |
12 ms |
4304 KB |
Output is correct |
35 |
Correct |
13 ms |
4444 KB |
Output is correct |
36 |
Correct |
14 ms |
4768 KB |
Output is correct |
37 |
Correct |
14 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
1372 KB |
Output is correct |
18 |
Correct |
4 ms |
1372 KB |
Output is correct |
19 |
Correct |
3 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1116 KB |
Output is correct |
21 |
Correct |
3 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1116 KB |
Output is correct |
23 |
Correct |
3 ms |
1116 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
19 ms |
5076 KB |
Output is correct |
26 |
Correct |
17 ms |
5236 KB |
Output is correct |
27 |
Correct |
18 ms |
5332 KB |
Output is correct |
28 |
Correct |
10 ms |
3932 KB |
Output is correct |
29 |
Correct |
12 ms |
4304 KB |
Output is correct |
30 |
Correct |
13 ms |
4444 KB |
Output is correct |
31 |
Correct |
14 ms |
4768 KB |
Output is correct |
32 |
Correct |
14 ms |
4440 KB |
Output is correct |
33 |
Correct |
0 ms |
432 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
360 KB |
Output is correct |
38 |
Correct |
100 ms |
45400 KB |
Output is correct |
39 |
Correct |
97 ms |
45388 KB |
Output is correct |
40 |
Correct |
98 ms |
45652 KB |
Output is correct |
41 |
Correct |
98 ms |
45600 KB |
Output is correct |
42 |
Correct |
260 ms |
54476 KB |
Output is correct |
43 |
Correct |
275 ms |
54460 KB |
Output is correct |
44 |
Correct |
263 ms |
54236 KB |
Output is correct |
45 |
Correct |
233 ms |
53960 KB |
Output is correct |
46 |
Correct |
110 ms |
45004 KB |
Output is correct |
47 |
Correct |
133 ms |
45512 KB |
Output is correct |
48 |
Correct |
178 ms |
50628 KB |
Output is correct |
49 |
Correct |
175 ms |
51892 KB |
Output is correct |
50 |
Correct |
87 ms |
26296 KB |
Output is correct |
51 |
Correct |
87 ms |
25564 KB |
Output is correct |
52 |
Correct |
191 ms |
50884 KB |
Output is correct |
53 |
Correct |
190 ms |
50456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1072 KB |
Output is correct |
2 |
Correct |
2 ms |
884 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
852 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Correct |
2 ms |
856 KB |
Output is correct |
9 |
Correct |
2 ms |
952 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
432 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
360 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
775 ms |
285164 KB |
Output is correct |
8 |
Correct |
1701 ms |
605888 KB |
Output is correct |
9 |
Correct |
1670 ms |
604912 KB |
Output is correct |
10 |
Correct |
1705 ms |
605232 KB |
Output is correct |
11 |
Correct |
656 ms |
297416 KB |
Output is correct |
12 |
Correct |
1258 ms |
560004 KB |
Output is correct |
13 |
Correct |
1343 ms |
596156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
1372 KB |
Output is correct |
18 |
Correct |
4 ms |
1372 KB |
Output is correct |
19 |
Correct |
3 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1116 KB |
Output is correct |
21 |
Correct |
3 ms |
1112 KB |
Output is correct |
22 |
Correct |
3 ms |
1116 KB |
Output is correct |
23 |
Correct |
3 ms |
1116 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
19 ms |
5076 KB |
Output is correct |
26 |
Correct |
17 ms |
5236 KB |
Output is correct |
27 |
Correct |
18 ms |
5332 KB |
Output is correct |
28 |
Correct |
10 ms |
3932 KB |
Output is correct |
29 |
Correct |
12 ms |
4304 KB |
Output is correct |
30 |
Correct |
13 ms |
4444 KB |
Output is correct |
31 |
Correct |
14 ms |
4768 KB |
Output is correct |
32 |
Correct |
14 ms |
4440 KB |
Output is correct |
33 |
Correct |
100 ms |
45400 KB |
Output is correct |
34 |
Correct |
97 ms |
45388 KB |
Output is correct |
35 |
Correct |
98 ms |
45652 KB |
Output is correct |
36 |
Correct |
98 ms |
45600 KB |
Output is correct |
37 |
Correct |
260 ms |
54476 KB |
Output is correct |
38 |
Correct |
275 ms |
54460 KB |
Output is correct |
39 |
Correct |
263 ms |
54236 KB |
Output is correct |
40 |
Correct |
233 ms |
53960 KB |
Output is correct |
41 |
Correct |
110 ms |
45004 KB |
Output is correct |
42 |
Correct |
133 ms |
45512 KB |
Output is correct |
43 |
Correct |
178 ms |
50628 KB |
Output is correct |
44 |
Correct |
175 ms |
51892 KB |
Output is correct |
45 |
Correct |
87 ms |
26296 KB |
Output is correct |
46 |
Correct |
87 ms |
25564 KB |
Output is correct |
47 |
Correct |
191 ms |
50884 KB |
Output is correct |
48 |
Correct |
190 ms |
50456 KB |
Output is correct |
49 |
Correct |
2 ms |
1072 KB |
Output is correct |
50 |
Correct |
2 ms |
884 KB |
Output is correct |
51 |
Correct |
2 ms |
860 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
2 ms |
1112 KB |
Output is correct |
54 |
Correct |
2 ms |
852 KB |
Output is correct |
55 |
Correct |
2 ms |
860 KB |
Output is correct |
56 |
Correct |
2 ms |
856 KB |
Output is correct |
57 |
Correct |
2 ms |
952 KB |
Output is correct |
58 |
Correct |
1 ms |
348 KB |
Output is correct |
59 |
Correct |
1 ms |
752 KB |
Output is correct |
60 |
Correct |
1 ms |
348 KB |
Output is correct |
61 |
Correct |
775 ms |
285164 KB |
Output is correct |
62 |
Correct |
1701 ms |
605888 KB |
Output is correct |
63 |
Correct |
1670 ms |
604912 KB |
Output is correct |
64 |
Correct |
1705 ms |
605232 KB |
Output is correct |
65 |
Correct |
656 ms |
297416 KB |
Output is correct |
66 |
Correct |
1258 ms |
560004 KB |
Output is correct |
67 |
Correct |
1343 ms |
596156 KB |
Output is correct |
68 |
Correct |
0 ms |
432 KB |
Output is correct |
69 |
Correct |
0 ms |
348 KB |
Output is correct |
70 |
Correct |
0 ms |
348 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
0 ms |
360 KB |
Output is correct |
73 |
Correct |
1542 ms |
642944 KB |
Output is correct |
74 |
Correct |
1515 ms |
642884 KB |
Output is correct |
75 |
Correct |
1520 ms |
643028 KB |
Output is correct |
76 |
Correct |
1501 ms |
642940 KB |
Output is correct |
77 |
Correct |
3771 ms |
776688 KB |
Output is correct |
78 |
Correct |
1362 ms |
356600 KB |
Output is correct |
79 |
Correct |
1731 ms |
433704 KB |
Output is correct |
80 |
Correct |
2531 ms |
685848 KB |
Output is correct |
81 |
Correct |
1463 ms |
373064 KB |
Output is correct |
82 |
Correct |
2024 ms |
550940 KB |
Output is correct |
83 |
Correct |
2644 ms |
711328 KB |
Output is correct |
84 |
Correct |
1603 ms |
365484 KB |
Output is correct |
85 |
Correct |
2838 ms |
711528 KB |
Output is correct |
86 |
Correct |
2869 ms |
707120 KB |
Output is correct |
87 |
Correct |
2189 ms |
456012 KB |
Output is correct |
88 |
Correct |
3511 ms |
775684 KB |
Output is correct |
89 |
Correct |
3659 ms |
777572 KB |
Output is correct |
90 |
Correct |
3885 ms |
777048 KB |
Output is correct |