#include "squarerect.h"
#include <cstdlib>
extern bool inside_shape(int,int);
bool am_i_square(int n,int q){
int c=(n+1)/2,s=(n+10)/11,p=c,o=c;
for(int i=1;i<=10;i++){
int t=i*s;
if(t>n)t=n;
if(inside_shape(c,t)){p=c;o=t;break;}
}
int l=1,r=p,m;
while(l<r){
m=(l+r)/2;
if(inside_shape(m,o))r=m;
else l=m+1;
}
int f=l;
l=p;r=n;
while(l<r){
m=(l+r+1)/2;
if(inside_shape(m,o))l=m;
else r=m-1;
}
int g=l;
l=1;r=o;
while(l<r){
m=(l+r)/2;
if(inside_shape(p,m))r=m;
else l=m+1;
}
int h=l;
l=o;r=n;
while(l<r){
m=(l+r+1)/2;
if(inside_shape(p,m))l=m;
else r=m-1;
}
int k=l;
return (g-f)==(k-h);
}
# | 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... |