We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Points on a Rectangle
Points on a Rectangle
Sort by
recency
|
7 Discussions
|
Please Login in order to post a comment
def solve(coordinates):
Another approach: if the x coordinate is in [max_x, min_x] or the y_coordinate is in [max_y, min_y] for every point in the set, then it is a rectangle parallel to the axes because otherwise there would either be a point outside or inside the rectangle
include
include
include
include
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int t; scanf("%d",&t); while(t--) { int n,x[10],y[10],i,minx=10000,maxx=-10000,miny=10000,maxy=-10000; int flag=0; scanf("%d",&n); for(i=0;i=x[i]) minx=x[i]; if(maxx<=x[i]) maxx=x[i]; if(miny>=y[i]) miny=y[i]; if(maxy<=y[i]) maxy=y[i]; } //printf("%d\t%d\t%d\t%d\n",minx,maxx,miny,maxy); for(i=0;i
}
note that the question only asks for axis parallel rectangles, e.g. sides are either vertical or horizontal lines. Without this restriction, the problem would be significantly more nontrivial!