첫번째 코드
어느 난이도부터 시작해야 하나..하고 D4를 봤다가..너무 어려워서 D2로 시작하기로 했다.
이 문제는 조건을 설정하는 것이 중요한 문제이다.
언제 내부에 있는지, 외부에 있는지, 선에 걸쳐져 있는지 조건을 설정한 후
해당 조건에 맞는 코드를 작성하면 된다.
import sys
input = sys.stdin.readline
question_num = int(input())
for i in range(1, question_num + 1):
x1, y1, x2, y2 = map(int, input().split())
check = int(input())
inside_answer = 0
online_answer = 0
outside_answer = 0
for _ in range(check):
x, y = map(int, input().split())
if x1 < x < x2 and y1 < y < y2:
inside_answer += 1
elif ((x == x1 or x == x2) and y1 <= y <= y2) or (x1 <= x <= x2 and (y == y1 or y == y2)):
online_answer += 1
else:
outside_answer += 1
print(f'#{i} {inside_answer} {online_answer} {outside_answer}')
통과!
링크
programmers/SWEA/D2/22372. 직사각형과 점 at main · ornni/programmers
repository for recording Programmers Algorithm problem solving - ornni/programmers
github.com