# 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 ;
int ycoords ;
int minx, miny, maxx, maxy ;

ifstr >> xcoords >> ycoords ;
ifstr >> xcoords >> ycoords ;
ifstr >> xcoords >> ycoords ;
ifstr >> xcoords >> ycoords ;

minx = min(xcoords, min(xcoords, min(xcoords, xcoords))) ;
maxx = max(xcoords, max(xcoords, max(xcoords, xcoords))) ;
maxy = max(ycoords, max(ycoords, max(ycoords, ycoords))) ;
miny = min(ycoords, min(ycoords, min(ycoords, ycoords))) ;

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!