728x90
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com

import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int tc = 1; tc <= t; tc++) {
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int x2 = sc.nextInt();
int y2 = sc.nextInt();
int n = sc.nextInt();
int inCount=0;
int outCount=0;
int lineCount=0;
for(int i=0;i<n;i++) {
int tx = sc.nextInt();
int ty= sc.nextInt();
if(tx<x1||ty<y1||tx>x2||ty>y2) {
outCount++;
}
else if(tx>x1&&tx<x2&&ty>y1&&ty<y2) {
inCount++;
}
else {
lineCount++;
}
}
System.out.println("#"+tc+" "+inCount+" "+lineCount+" "+outCount);
}
}
}
라인 위에 점들은 까다롭기 때문에
점이 내부에 있는 것도 아니고 외부에 있는 것도 아니면
라인 위에 있다는 것을 이용했다.
728x90
'SW Expert Academy > SWEA D3' 카테고리의 다른 글
| [SW Expert Academy] 성공적인 공연 기획 (D3) (1) | 2024.10.03 |
|---|---|
| [SW Expert Academy] 항구에 들어오는 배 (D3) (0) | 2024.10.03 |
| [SW Expert Academy] 화섭이의 정수 나열 (D3) (0) | 2024.10.03 |
| [SW Expert Academy] 합성수 방정식 (D3) (0) | 2024.10.03 |
| [SW Expert Academy] 화섭이의 정수 나열 (D3) (0) | 2024.10.02 |