Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 열혈 tcp/ip 프로그래밍
- Spring
- redis
- 우아한 테크 세미나
- Four Squares
- C#
- 김영한
- 우아한레디스
- Operating System.
- OS
- 운영체제
- 스프링 입문
- 윤성우 저자
- 이펙티브코틀린
- inflearn
- BOJ
- HTTP
- C++
- 2475번
- TCP/IP
- Window-Via-c/c++
- 토마토
- 열혈 TCP/IP 소켓 프로그래밍
- 제프리리처
- n타일링2
- 에러핸들링
- FIFO paging
- Operating System
- 10026번
- 스프링 핵심 원리
Archives
- Today
- Total
나의 브을로오그으
[c++] 11651번 : 좌표 정렬하기2 본문
https://www.acmicpc.net/problem/11651
11651번: 좌표 정렬하기 2
첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.
www.acmicpc.net
#include <cstdio>
#include <algorithm>
using namespace std;
char buf[1 << 15];
int idx = 1 << 15;
inline char read()
{
if (idx == 1 << 15)
{
fread(buf, 1, 1 << 15, stdin);
idx = 0;
}
return buf[idx++];
}
inline int readInt()
{
int sum = 0;
int flag = 1;
char now = read();
while (now == ' ' || now == '\n') now = read();
if (now == '-')
{
flag = -1;
now = read();
}
while (now >= '0' && now <= '9')
{
sum = sum * 10 + now - 48;
now = read();
}
return sum * flag;
}
int compare(pair<int, int> p1, pair<int, int> p2)
{
return p1.second == p2.second ? p1.first < p2.first : p1.second < p2.second;
}
int main()
{
int n;
n = readInt();
pair<int, int> p[100000];
for (int i = 0; i < n; ++i)
{
p[i].first = readInt();
p[i].second = readInt();
}
sort(p, p + n, compare);
for (int i = 0; i < n; ++i)
{
printf("%d %d\n", p[i].first, p[i].second);
}
return 0;
}
'알고리즘 > BaekJoon' 카테고리의 다른 글
[c++] 15829번 : Hashing (0) | 2022.05.16 |
---|---|
[c++] 11866번 : 요세푸스 문제 0 (0) | 2022.05.12 |
[c++] 11650번 : 좌표 정렬하기 (0) | 2022.05.12 |
[c++] 11050번 : 이항 계수 1 (0) | 2022.05.10 |
[c++] 10989번 : 수 정렬하기3 (0) | 2022.05.10 |