Skip to content

Commit

Permalink
🐸�
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdls111 committed Feb 21, 2022
1 parent 7fbb76e commit 30a316c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 17000/17619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys

input = sys.stdin.readline

N, Q = map(int, input().split())

line = [[*map(int, input().split())] + [i] for i in range(1, N + 1)] # 원래 인덱스를 저장해야 하므로!!
line.sort(key=lambda x: (x[0], -x[1]))

connect = [0] * (N + 1)

right = line[0][1]
idx = 0
for i in range(1, N):
a, b = line[i][0], line[i][1]
if right < a: # 안 겹칠 때
right = b
idx += 1
connect[line[i][3]] = idx

elif right < b: # 겹칠 때
right = b
connect[line[i][3]] = idx # 원래 인덱스 위치에 저장
elif b <= right: # 겹칠 때
connect[line[i][3]] = idx # 원래 인덱스 위치에 저장

for _ in range(Q):
x1, x2 = map(int, input().split())
if connect[x1] == connect[x2]:
print(1)
else:
print(0)
2 changes: 2 additions & 0 deletions problem_lists/2022.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@
[1715. 카드 정렬하기](https://www.acmicpc.net/problem/1715) 🌸[설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1715-%EC%B9%B4%EB%93%9C-%EC%A0%95%EB%A0%AC%ED%95%98%EA%B8%B0)

[21202. Conquest](https://www.acmicpc.net/problem/21202) 🦄[설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-21202-Conquest)

[17619 개구리 점프](https://www.acmicpc.net/problem/17619) 🐸 [설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-17619-%EA%B0%9C%EA%B5%AC%EB%A6%AC-%EC%A0%90%ED%94%84)

0 comments on commit 30a316c

Please sign in to comment.