Submission #298475

#TimeUsernameProblemLanguageResultExecution timeMemory
298475daniel920712Rectangles (IOI19_rect)C++14
Compilation error
0 ms0 KiB
#include "rect.h"
#include <stdio.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,n,big=0,ok;
    long long ans=0;
    N=all.size();
    M=all[0].size();
    if(N==3)
    {

        for(i=1;i<M-1;i++)
        {
            ok=1;
            big=0;
            for(j=i;j<M-1;j++)
            {
                if(all[1][j]>=all[0][j]||all[1][j]>=all[2][j]) ok=0;
                big=max(big,all[1][j]);
                if(ok&&big<min(all[1][i-1],all[1][j+1])) ans++;
            }
        }
        return ans;
    }
    else if(N<3) return 0;
    else
    {
        for(i=1;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;
                    can1[i][j][k]+=can1[i-1][j][k];
                }
            }
        }
        for(i=1;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[j-1][i]&&big<all[k+1][i]) can2[i][j][k]=1;
                    can2[i][j][k]+=can2[i-1][j][k];
                }
            }
        }
        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++)
                    {

                        if(can1[j][k][l]-can1[i-1][k][l]==j-i+1&&can2[l][i][j]-can2[k-1][i][j]==l-k+1) ans++;

                    }
                }
            }
        }
    }
	return ans;
}

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:9:21: warning: unused variable 'm' [-Wunused-variable]
    9 |     int N,M,i,j,k,l,m,n,big=0,ok;
      |                     ^
rect.cpp:9:23: warning: unused variable 'n' [-Wunused-variable]
    9 |     int N,M,i,j,k,l,m,n,big=0,ok;
      |                       ^
/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