# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1219705 | mariamtsagareli | Square or Rectangle? (NOI19_squarerect) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
bool am_i_square(int n,int q){
int c=(n+1)/2;
int a=1,b=n;
while(a<b){
int m=(a+b)/2;
if(inside_shape(m,c)) b=m;
else a=m+1;
}
int t=a;
a=1; b=n;
while(a<b){
int m=(a+b+1)/2;
if(inside_shape(m,c)) a=m;
else b=m-1;
}
int d=a;
int l=1,r=n;
while(l<r){
int m=(l+r)/2;
if(inside_shape(c,m)) r=m;
else l=m+1;
}
int e=l;
l=1; r=n;
while(l<r){
int m=(l+r+1)/2;
if(inside_shape(c,m)) l=m;
else r=m-1;
}
int f=l;
return d-t==f-e;
}