I can't figure out why my code isn't working

Square_Pasture

#include <fstream>
#include <math.h>
#include <vector>
using namespace std ;

ifstream ifstr ("square.in") ;
ofstream ofstr ("square.out") ;

int main() {
	int xcoords[4] ;
	int ycoords[4] ;
	int minx, miny, maxx, maxy ;
	
	ifstr >> xcoords[0] >> ycoords[0] ;
	ifstr >> xcoords[1] >> ycoords[1] ;
	ifstr >> xcoords[2] >> ycoords[2] ;
	ifstr >> xcoords[3] >> ycoords[3] ;

	minx = min(xcoords[3], min(xcoords[2], min(xcoords[0], xcoords[1]))) ;
	maxx = max(xcoords[3], max(xcoords[2], max(xcoords[0], xcoords[1]))) ;
	maxy = max(ycoords[3], max(ycoords[2], max(ycoords[0], ycoords[1]))) ;
	miny = min(ycoords[3], min(ycoords[2], min(ycoords[0], ycoords[1]))) ;

	int ans_sqrt = max(abs(minx-maxx), abs(miny-minx)) ;

	ofstr << pow(ans_sqrt, 2) << endl ;
	return 0 ;
}

I stored the coordinate data in the xcoords and ycoords arrays. I used the intersections of the x and y, found the maximum of them, and I squared that value to get the answer.

I couldn’t figure out my problem, so the only thing I tried was to read the question multiple times. The first test case works along with others, but some are labeled incorrect when I submit it through the main USACO page.

I think one of the variables might be incorrect, perhaps try changing the minx into maxy in the line with the definition of the variableans_sqrt.

int ans_sqrt = max(abs(minx-maxx), abs(miny-maxy));

Hope that helps!