Link: USACO
Here is my code:
import java.util.;
import java.io.;
class square{
public static void main (String[] args) throws IOException{
Scanner in = new Scanner(new File(“square.in”));
FileWriter out = new FileWriter(“square.out”);
int x1 = in.nextInt();
int y1 = in.nextInt();
int x2 =in.nextInt();
int y2 = in.nextInt();
//rect two
int a1 = in.nextInt();
int b1 = in.nextInt();
int a2 = in.nextInt();
int b2 = in.nextInt();
int width = (x2 - x1) + (a2 -a1) + (Math.max(a2,x1) - Math.min(a2,x1));
out.write(""+ width*width);
out.close();
}
}
It passes 4 of the 10 test cases. Is it an issue with the logic in my code, or run time and memory?