Submission #1225817

#TimeUsernameProblemLanguageResultExecution timeMemory
1225817mariamtsagareliSquare or Rectangle? (NOI19_squarerect)C++17
Compilation error
0 ms0 KiB
bool am_i_square(int n,int q){
    int i,j,x1,x2,y1,y2,x0,y0,l,h,m;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(inside_shape(i,j)){
                x0=i; y0=j; goto f;
            }
    f:
    l=1; h=x0;
    while(l<h){
        m=(l+h)/2;
        if(inside_shape(m,y0)) h=m;
        else l=m+1;
    }
    x1=l;
    l=x0; h=n;
    while(l<h){
        m=(l+h+1)/2;
        if(inside_shape(m,y0)) l=m;
        else h=m-1;
    }
    x2=l;
    l=1; h=y0;
    while(l<h){
        m=(l+h)/2;
        if(inside_shape(x0,m)) h=m;
        else l=m+1;
    }
    y1=l;
    l=y0; h=n;
    while(l<h){
        m=(l+h+1)/2;
        if(inside_shape(x0,m)) l=m;
        else h=m-1;
    }
    y2=l;
    return (x2-x1)==(y2-y1);
}

Compilation message (stderr)

squarerect.cpp: In function 'bool am_i_square(int, int)':
squarerect.cpp:5:16: error: 'inside_shape' was not declared in this scope
    5 |             if(inside_shape(i,j)){
      |                ^~~~~~~~~~~~
squarerect.cpp:12:12: error: 'inside_shape' was not declared in this scope
   12 |         if(inside_shape(m,y0)) h=m;
      |            ^~~~~~~~~~~~
squarerect.cpp:19:12: error: 'inside_shape' was not declared in this scope
   19 |         if(inside_shape(m,y0)) l=m;
      |            ^~~~~~~~~~~~
squarerect.cpp:26:12: error: 'inside_shape' was not declared in this scope
   26 |         if(inside_shape(x0,m)) h=m;
      |            ^~~~~~~~~~~~
squarerect.cpp:33:12: error: 'inside_shape' was not declared in this scope
   33 |         if(inside_shape(x0,m)) l=m;
      |            ^~~~~~~~~~~~