DHistory
[Baekjoon] Sort - 11650 좌표 정렬하기 본문
문제
11650번: 좌표 정렬하기
첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.
www.acmicpc.net
풀이
import sys
n = int(sys.stdin.readline().rstrip())
coordinates = []
for _ in range(n):
x, y = map(int, sys.stdin.readline().rstrip().split())
coordinates.append((x, y))
def solution(coordinates):
return sorted(coordinates, key=lambda x: (x[0], x[1]))
for x, y in solution(coordinates):
print(x, y, end='\n')
채점 결과
'Computer Science > Algorithm' 카테고리의 다른 글
[Baekjoon] Sort - 10815 숫자 카드 (0) | 2023.09.08 |
---|---|
[Baekjoon] Sort - 나이순 정렬 (0) | 2023.09.08 |
[Baekjoon] Sort - 1181 단어 정렬 (0) | 2023.09.08 |
[Baekjoon] Sort - 2751 수 정렬하기 2 (0) | 2023.09.08 |
[Baekjoon] DFS/BFS - 1325 효율적인 해킹 (0) | 2023.09.08 |