Programming/Python & Data Structures
[Baekjoon/Python3] 11650번 좌표 정렬하기
HooNeee
2020. 12. 7. 00:33
[Baekjoon/Python3] 11650번 좌표 정렬하기
11650번: 좌표 정렬하기
첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.
www.acmicpc.net
# 메모리 : 49204KB / 시간 : 4876ms / 코드 길이 : 163B
n = int(input())
locations = []
for i in range(n):
locations.append(list(map(int, input().split())))
locations.sort()
for j in locations:
print(j[0], j[1])
# 메모리 : 58508KB / 시간 : 464ms / 코드 길이 : 266B
import sys
n = int(sys.stdin.readline())
locations = []
for i in range(n):
locations.append(list(map(int, sys.stdin.readline().split())))
locations.sort(key = lambda lo: [lo[0], lo[1]])
for j in locations:
sys.stdout.write(str(j[0]) + ' ' + str(j[1]) + '\n')