From 30a316c47e534bef436aaefb4d19e130b8b626f8 Mon Sep 17 00:00:00 2001 From: Seoin <68271159+tjdls111@users.noreply.github.com> Date: Mon, 21 Feb 2022 23:25:31 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B8=EF=BF=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 17000/17619.py | 32 ++++++++++++++++++++++++++++++++ problem_lists/2022.md | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 17000/17619.py diff --git a/17000/17619.py b/17000/17619.py new file mode 100644 index 0000000..2c9e5df --- /dev/null +++ b/17000/17619.py @@ -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) diff --git a/problem_lists/2022.md b/problem_lists/2022.md index 94aad75..6387b3b 100644 --- a/problem_lists/2022.md +++ b/problem_lists/2022.md @@ -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)