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"
using namespace std;
int can1[705][705][705]={0};
int can2[705][705][705]={0};
long long count_rectangles(vector< vector<int> > all)
{
int N,M,i,j,k,l,m,big=0,ans=0,ok;
N=all.size();
M=all[0].size();
for(i=0;i<N;i++)
{
for(j=1;j<M;j++)
{
big=0;
for(k=j;k<M-1;k++)
{
big=max(big,all[i][k]);
if(big<all[i][j-1]&&big<all[i][k-1]) can1[i][j][k]=1;
}
}
}
for(i=0;i<M;i++)
{
for(j=1;j<N;j++)
{
big=0;
for(k=j;k<N-1;k++)
{
big=max(big,all[k][i]);
if(big<all[i][j-1]&&big<all[i][k-1]) can2[i][j][k]=1;
}
}
}
for(i=1;i<N-1;i++)
{
for(j=i;j<N-1;j++)
{
for(k=1;k<M-1;k++)
{
for(l=k;l<M-1;l++)
{
ok=1;
for(m=i;m<=j;m++) ok=ok&&can1[i][k][l];
for(m=k;m<=l;m++) ok=ok&&can2[l][i][j];
if(ok) ans++;
}
}
}
}
return ans;
}
Compilation message (stderr)
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(vterminate.o): In function `__gnu_cxx::__verbose_terminate_handler()':
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x1a): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(vterminate.o): In function `__gnu_cxx::__verbose_terminate_handler()':
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x27): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0x18): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0x2c): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0x53): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0xb7): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0xc3): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::free(void*) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool4freeEPv.constprop.0+0x116): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::allocate(unsigned long) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool8allocateEm.constprop.0+0x19): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::allocate(unsigned long) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool8allocateEm.constprop.0+0x3b): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZN12_GLOBAL__N_114emergency_poolE'
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a(eh_alloc.o): In function `(anonymous namespace)::pool::allocate(unsigned long) [clone .constprop.0]':
(.text._ZN12_GLOBAL__N_14pool8allocateEm.constprop.0+0x53): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status