Algorithm
BOJ - 11650번 - 좌표 정렬하기
테니드2
2021. 4. 8. 00:36
11650번: 좌표 정렬하기
첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.
www.acmicpc.net
코드:
def solution(count):
data = []
for _ in range(count):
x,y = map(int,input().split())
temp = []
temp.append(x)
temp.append(y)
data.append(temp)
data.sort(key=lambda x: (x[0],x[1]))
for i in range(len(data)):
print(f'{data[i][0]} {data[i][1]}')
N = int(input())
solution(N)