Skip to content

Commit 30a316c

Browse files
committed
🐸�
1 parent 7fbb76e commit 30a316c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

17000/17619.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
N, Q = map(int, input().split())
6+
7+
line = [[*map(int, input().split())] + [i] for i in range(1, N + 1)] # 원래 인덱스를 저장해야 하므로!!
8+
line.sort(key=lambda x: (x[0], -x[1]))
9+
10+
connect = [0] * (N + 1)
11+
12+
right = line[0][1]
13+
idx = 0
14+
for i in range(1, N):
15+
a, b = line[i][0], line[i][1]
16+
if right < a: # 안 겹칠 때
17+
right = b
18+
idx += 1
19+
connect[line[i][3]] = idx
20+
21+
elif right < b: # 겹칠 때
22+
right = b
23+
connect[line[i][3]] = idx # 원래 인덱스 위치에 저장
24+
elif b <= right: # 겹칠 때
25+
connect[line[i][3]] = idx # 원래 인덱스 위치에 저장
26+
27+
for _ in range(Q):
28+
x1, x2 = map(int, input().split())
29+
if connect[x1] == connect[x2]:
30+
print(1)
31+
else:
32+
print(0)

problem_lists/2022.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@
5353
[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)
5454

5555
[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)
56+
57+
[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 commit comments

Comments
 (0)