import java.io.*;
class Main {
static int Bx, By, Gx, Gy;
static boolean checkInBox(int x, int y) {
return Math.min(Bx,Gx) <= x && x <= Math.max(Bx, Gx) && Math.min(By, Gy) <= y && y <= Math.max(By, Gy);
}
public static void main(String[] args) throws Exception {
int cnt = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String Bcoor = br.readLine();
String Gcoor = br.readLine();
String[] b = Bcoor.split(" "); // {"2", "1"}
Bx = Integer.parseInt(b[0]);
By = Integer.parseInt(b[1]);
String[] g = Gcoor.split(" "); // {"2", "1"}
Gx = Integer.parseInt(g[0]);
Gy = Integer.parseInt(g[1]);
int dx = Bx - Gx;
int dy = Gy - By;
int N = Integer.parseInt(br.readLine());
String tmp;
String[] arr;
for (int i=0; i<N; i++) {
tmp = br.readLine();
arr = tmp.split(" ");
if(checkInBox(Integer.parseInt(arr[0]), Integer.parseInt(arr[1]))) cnt++;
}
if(dx*dx + dy*dy < 25) {
System.out.println("NO");
return;
}
if (cnt >= 3) System.out.println("YES");
else System.out.println("NO");
}
}
Integer.parseInt는 Char에는 사용하지 못한다. 무조건 String이여야 한다.
따라서 .charAt()에다가 Integer.parseInt를 사용하지 못하고, .split() 한 다음에 [i]에다가 해야함.
그리고 여기서는 charAt이 별로인게 두 디짓 이상의 숫자라면 작동이 틀리게 된다.
Math.max와 Math.min 까먹지 말자
sqrt나 거듭제곱 operator가 없음을 까먹지 말자. dx*dx이런식으로 두번 곱하면 된다.
Math.sqrt는 double을 받고 double을 반환한다. 이는 부동소수점 오차를 발행할 수 있다. 또한 sqrt는 무거운 연산이다. 따라서 거듭제곱을 사용하는 게 낫다. (이 경우에는 5*5)