SlideShare a Scribd company logo
1 of 16
By POSTECH Computer Algorithm Team
자료 구조 & STL
곽성재
Data Structure
Contents
POSTECH Computer Algorithm Team
STL set, map 2
STL list, vector, queue 1
STL priority queue 3
연습문제 4
POSTECH Computer Algorithm Team
Concept
- Linked list 형식으로 구현되어 있다.
- Indexing 을 통한 access가 불가능하다.
- 원하는 위치의 iterator를 가지고 있어야 상수 시간 access가 가능하다.
STL list
POSTECH Computer Algorithm Team
Concept
#include <list>
std::list<int> l;
std::list<int> l = {1, 2, 3, 4}; // 초기화
std::list<std::string> l(100, “strstrstr”) // 100개의 “strstrstr”을 가진 list로 초기화
std::list<int> l(l2) // l2를 복사해서 초기화
STL list
POSTECH Computer Algorithm Team
Concept
- List와 마찬가지로 sequencial한 container
- Indexing을 통한 random access 가능 (따라서 탐색이 중요할 때 자주 사용됨)
- Insert/remove는 맨 뒤의 원소만 가능하며, push_back과 pop_back을 사용함
- Stack 구현에 사용될 수 있음
- STL vector 사용법만 알아 두면 STL stack을 굳이 사용할 필요가 없다.
STL vector
POSTECH Computer Algorithm Team
Concept
- List와 동일하게 초기화해서 사용할 수 있음
#include <vector>
std::vector<int> v;
std::vector<int> v = {1, 2, 3, 4}; // 초기화
std::vector<std::string> v(100, “strstrstr”) // 100개의 “strstrstr”을 가진 vector로 초기화
std::vector<int> v(v2) // v2를 복사해서 초기화
STL vector
POSTECH Computer Algorithm Team
Concept
- 큐는 FIFO(First In First Out) 의 특징을 가진다. (처음으로 Insert한 것이 처음으로 Delete된다)
- Push : 맨 뒤에 데이터를 삽입한다.
- Back : 맨 뒤의 데이터를 참조한다.
- Pop : 맨 앞의 데이터를 삭제한다.
- Front : 맨 앞의 데이터를 참조한다.
STL queue
POSTECH Computer Algorithm Team
Concept
#include <queue>
std::queue<int> q;
std::queue<int> q(deq) // std::deque deq를 복사해서 초기화
q = {1, 2, 3} 과 같이 초기화 할 수 없다는 점에 주의하자.
또한 iterable하지 않아서 오직 맨 앞과 맨 뒤의 원소만 참조 가능하다. (q.begin()이나 q.end() 메소드가 없다)
STL queue
POSTECH Computer Algorithm Team
Concept
- STL에서 스택과 큐를 합쳐놓은 듯한 deque가 존재한다.
- 앞뒤에서 삭제, 삽입, 참조를 하는 push_back, push_front, pop_back, … 등의 메소드가 있다.
- Detail이 궁금하다면 Google을 잘 활용하도록 하자.
STL deque
POSTECH Computer Algorithm Team
Concept
- Unique한 원소들을 담는 container
- Tree 구조로 이루어져 있어 삽입, 삭제, 탐색이 전부 O(log N) 의 시간복잡도를 가진다.
- Find : 해당 원소의 iterator를 반환
- Erase : 해당 원소를 삭제
- Insert : 원소를 set에 삽입
- Merge : 다른 set과의 union을 만들어 줌
STL set
POSTECH Computer Algorithm Team
Concept
- Key–value mapping을 저장하는 container
- Set과 마찬가지로 내부는 tree 구조를 가지므로 원소의 삽입, 삭제, 참조가 O(log N)의 시간복잡도를 가진다.
- m.at(key) 또는 m[key] : key에 해당하는 value 참조
- m[key] = value 또는 m.insert() :
- m.find(key) : m.at과 비슷하지만 iterator를 반환
- m.erase(key) : key-value 쌍을 map에서 제거
STL map
POSTECH Computer Algorithm Team
Concept
- 원소를 임의의 순서로 넣어도 꺼낼 때는 일정한 순서대로 나오도록 구현한 자료구조
- <queue>에 정의되어 있음
- Indexing 을 통한 random access가 불가능, iterable 하지도 않음
- Push : 원소를 집어넣음
- Pop : (default) 가장 큰 원소를 꺼냄
- Top : 가장 큰 원소를 참조
STL priority queue
POSTECH Computer Algorithm Team
Concept
#include <queue>
pritority_queue<int> pq;
pq.push(1);
pq.push(3);
pq.push(2);
// result: 3, 2, 1
pq.pop();
pq.pop();
pq.pop();
STL priority queue
POSTECH Computer Algorithm Team
Concept
#include <queue>
pritority_queue<int, vector<int>, greater<int>> pq;
pq.push(1);
pq.push(3);
pq.push(2);
// result: 1, 2, 3
pq.pop();
pq.pop();
pq.pop();
STL priority queue
POSTECH Computer Algorithm Team
Concept
#include <queue>
struct A {
int x;
}
struct op {
bool operator()(A a1, A a2) {
return a1.x > a2.x; // 작은것부터 나옴
}
};
pritority_queue<A, vector<A>, op> pq;
STL priority queue
POSTECH Computer Algorithm Team
More
- https://algospot.com/judge/problem/read/JOSEPHUS
- https://www.acmicpc.net/problem/2504
- https://algospot.com/judge/problem/read/ITES
- https://www.acmicpc.net/problem/6549

More Related Content

What's hot

2015-2 MODA 두 번째 스터디
2015-2 MODA 두 번째 스터디 2015-2 MODA 두 번째 스터디
2015-2 MODA 두 번째 스터디 SKKU
 
[Swift] Data Structure - Stack
[Swift] Data Structure - Stack[Swift] Data Structure - Stack
[Swift] Data Structure - StackBill Kim
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율S.O.P.T - Shout Our Passion Together
 
Python 강좌 발표 자료
Python 강좌 발표 자료Python 강좌 발표 자료
Python 강좌 발표 자료Soobin Jung
 
[Swift] Data Structure - Array
[Swift] Data Structure - Array[Swift] Data Structure - Array
[Swift] Data Structure - ArrayBill Kim
 
실용주의 디자인패턴 2 인터페이스로 프로그래밍하기
실용주의 디자인패턴   2 인터페이스로 프로그래밍하기실용주의 디자인패턴   2 인터페이스로 프로그래밍하기
실용주의 디자인패턴 2 인터페이스로 프로그래밍하기Cosmos Shin
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐S.O.P.T - Shout Our Passion Together
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리S.O.P.T - Shout Our Passion Together
 
Graph mst
Graph mstGraph mst
Graph mstGNGLB
 
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree승혁 조
 
[Swift] Tuple
[Swift] Tuple[Swift] Tuple
[Swift] TupleBill Kim
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산S.O.P.T - Shout Our Passion Together
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트S.O.P.T - Shout Our Passion Together
 

What's hot (13)

2015-2 MODA 두 번째 스터디
2015-2 MODA 두 번째 스터디 2015-2 MODA 두 번째 스터디
2015-2 MODA 두 번째 스터디
 
[Swift] Data Structure - Stack
[Swift] Data Structure - Stack[Swift] Data Structure - Stack
[Swift] Data Structure - Stack
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
 
Python 강좌 발표 자료
Python 강좌 발표 자료Python 강좌 발표 자료
Python 강좌 발표 자료
 
[Swift] Data Structure - Array
[Swift] Data Structure - Array[Swift] Data Structure - Array
[Swift] Data Structure - Array
 
실용주의 디자인패턴 2 인터페이스로 프로그래밍하기
실용주의 디자인패턴   2 인터페이스로 프로그래밍하기실용주의 디자인패턴   2 인터페이스로 프로그래밍하기
실용주의 디자인패턴 2 인터페이스로 프로그래밍하기
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐
[SOPT] 데이터 구조 및 알고리즘 스터디 - #04 : 트리 기초, 이진 트리, 우선순위 큐
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리
[SOPT] 데이터 구조 및 알고리즘 스터디 - #05 : AVL 트리
 
Graph mst
Graph mstGraph mst
Graph mst
 
02. binary search tree
02. binary search tree02. binary search tree
02. binary search tree
 
[Swift] Tuple
[Swift] Tuple[Swift] Tuple
[Swift] Tuple
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트
[SOPT] 데이터 구조 및 알고리즘 스터디 - #01 : 개요, 점근적 복잡도, 배열, 연결리스트
 

Similar to Data structure review (summer study)

[Swift] Data Structure - Queue
[Swift] Data Structure - Queue[Swift] Data Structure - Queue
[Swift] Data Structure - QueueBill Kim
 
개경프 1주차 Stl study
개경프 1주차 Stl study개경프 1주차 Stl study
개경프 1주차 Stl study경 송
 
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용 [GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용 Sehyeon Nam
 
[Algorithm] Counting Sort
[Algorithm] Counting Sort[Algorithm] Counting Sort
[Algorithm] Counting SortBill Kim
 
자바로 배우는 자료구조
자바로 배우는 자료구조자바로 배우는 자료구조
자바로 배우는 자료구조중선 곽
 
[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue[Swift] Data Structure - Dequeue
[Swift] Data Structure - DequeueBill Kim
 
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리ultrasuperrok
 
[Swift] Data Structure - Heap
[Swift] Data Structure - Heap[Swift] Data Structure - Heap
[Swift] Data Structure - HeapBill Kim
 
데이터 분석 3 - Java Collection Framework와 ArrayList
데이터 분석 3 - Java Collection Framework와 ArrayList데이터 분석 3 - Java Collection Framework와 ArrayList
데이터 분석 3 - Java Collection Framework와 ArrayListJaewook Byun
 
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자Jaewook Byun
 
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기Jaewook Byun
 
Binary search tree
Binary search treeBinary search tree
Binary search treeMelon Lemon
 
Java advancd ed10
Java advancd ed10Java advancd ed10
Java advancd ed10hungrok
 
Collection framework
Collection frameworkCollection framework
Collection frameworkssuser34b989
 
[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search TreeBill Kim
 
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자Jaewook Byun
 
파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기Yong Joon Moon
 

Similar to Data structure review (summer study) (19)

[Swift] Data Structure - Queue
[Swift] Data Structure - Queue[Swift] Data Structure - Queue
[Swift] Data Structure - Queue
 
개경프 1주차 Stl study
개경프 1주차 Stl study개경프 1주차 Stl study
개경프 1주차 Stl study
 
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용 [GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
 
[Algorithm] Counting Sort
[Algorithm] Counting Sort[Algorithm] Counting Sort
[Algorithm] Counting Sort
 
자바로 배우는 자료구조
자바로 배우는 자료구조자바로 배우는 자료구조
자바로 배우는 자료구조
 
Light Tutorial Python
Light Tutorial PythonLight Tutorial Python
Light Tutorial Python
 
STL study (skyLab)
STL study (skyLab)STL study (skyLab)
STL study (skyLab)
 
[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue
 
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리
코딩테스트 합격자 되기 2주차 스터디 - 리스트_딕셔너리
 
[Swift] Data Structure - Heap
[Swift] Data Structure - Heap[Swift] Data Structure - Heap
[Swift] Data Structure - Heap
 
데이터 분석 3 - Java Collection Framework와 ArrayList
데이터 분석 3 - Java Collection Framework와 ArrayList데이터 분석 3 - Java Collection Framework와 ArrayList
데이터 분석 3 - Java Collection Framework와 ArrayList
 
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자
데이터 분석 6 - 나만의 배열 기반 LIST, MyLinkedList를 만들어보자
 
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기
데이터 분석 5 - Java Collection Framework - LinkedList 파헤치기
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Java advancd ed10
Java advancd ed10Java advancd ed10
Java advancd ed10
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree
 
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자
데이터 분석 4 - 나만의 배열 기반 LIST, MyArrayList를 만들어보자
 
파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기
 

Data structure review (summer study)

  • 1. By POSTECH Computer Algorithm Team 자료 구조 & STL 곽성재 Data Structure
  • 2. Contents POSTECH Computer Algorithm Team STL set, map 2 STL list, vector, queue 1 STL priority queue 3 연습문제 4
  • 3. POSTECH Computer Algorithm Team Concept - Linked list 형식으로 구현되어 있다. - Indexing 을 통한 access가 불가능하다. - 원하는 위치의 iterator를 가지고 있어야 상수 시간 access가 가능하다. STL list
  • 4. POSTECH Computer Algorithm Team Concept #include <list> std::list<int> l; std::list<int> l = {1, 2, 3, 4}; // 초기화 std::list<std::string> l(100, “strstrstr”) // 100개의 “strstrstr”을 가진 list로 초기화 std::list<int> l(l2) // l2를 복사해서 초기화 STL list
  • 5. POSTECH Computer Algorithm Team Concept - List와 마찬가지로 sequencial한 container - Indexing을 통한 random access 가능 (따라서 탐색이 중요할 때 자주 사용됨) - Insert/remove는 맨 뒤의 원소만 가능하며, push_back과 pop_back을 사용함 - Stack 구현에 사용될 수 있음 - STL vector 사용법만 알아 두면 STL stack을 굳이 사용할 필요가 없다. STL vector
  • 6. POSTECH Computer Algorithm Team Concept - List와 동일하게 초기화해서 사용할 수 있음 #include <vector> std::vector<int> v; std::vector<int> v = {1, 2, 3, 4}; // 초기화 std::vector<std::string> v(100, “strstrstr”) // 100개의 “strstrstr”을 가진 vector로 초기화 std::vector<int> v(v2) // v2를 복사해서 초기화 STL vector
  • 7. POSTECH Computer Algorithm Team Concept - 큐는 FIFO(First In First Out) 의 특징을 가진다. (처음으로 Insert한 것이 처음으로 Delete된다) - Push : 맨 뒤에 데이터를 삽입한다. - Back : 맨 뒤의 데이터를 참조한다. - Pop : 맨 앞의 데이터를 삭제한다. - Front : 맨 앞의 데이터를 참조한다. STL queue
  • 8. POSTECH Computer Algorithm Team Concept #include <queue> std::queue<int> q; std::queue<int> q(deq) // std::deque deq를 복사해서 초기화 q = {1, 2, 3} 과 같이 초기화 할 수 없다는 점에 주의하자. 또한 iterable하지 않아서 오직 맨 앞과 맨 뒤의 원소만 참조 가능하다. (q.begin()이나 q.end() 메소드가 없다) STL queue
  • 9. POSTECH Computer Algorithm Team Concept - STL에서 스택과 큐를 합쳐놓은 듯한 deque가 존재한다. - 앞뒤에서 삭제, 삽입, 참조를 하는 push_back, push_front, pop_back, … 등의 메소드가 있다. - Detail이 궁금하다면 Google을 잘 활용하도록 하자. STL deque
  • 10. POSTECH Computer Algorithm Team Concept - Unique한 원소들을 담는 container - Tree 구조로 이루어져 있어 삽입, 삭제, 탐색이 전부 O(log N) 의 시간복잡도를 가진다. - Find : 해당 원소의 iterator를 반환 - Erase : 해당 원소를 삭제 - Insert : 원소를 set에 삽입 - Merge : 다른 set과의 union을 만들어 줌 STL set
  • 11. POSTECH Computer Algorithm Team Concept - Key–value mapping을 저장하는 container - Set과 마찬가지로 내부는 tree 구조를 가지므로 원소의 삽입, 삭제, 참조가 O(log N)의 시간복잡도를 가진다. - m.at(key) 또는 m[key] : key에 해당하는 value 참조 - m[key] = value 또는 m.insert() : - m.find(key) : m.at과 비슷하지만 iterator를 반환 - m.erase(key) : key-value 쌍을 map에서 제거 STL map
  • 12. POSTECH Computer Algorithm Team Concept - 원소를 임의의 순서로 넣어도 꺼낼 때는 일정한 순서대로 나오도록 구현한 자료구조 - <queue>에 정의되어 있음 - Indexing 을 통한 random access가 불가능, iterable 하지도 않음 - Push : 원소를 집어넣음 - Pop : (default) 가장 큰 원소를 꺼냄 - Top : 가장 큰 원소를 참조 STL priority queue
  • 13. POSTECH Computer Algorithm Team Concept #include <queue> pritority_queue<int> pq; pq.push(1); pq.push(3); pq.push(2); // result: 3, 2, 1 pq.pop(); pq.pop(); pq.pop(); STL priority queue
  • 14. POSTECH Computer Algorithm Team Concept #include <queue> pritority_queue<int, vector<int>, greater<int>> pq; pq.push(1); pq.push(3); pq.push(2); // result: 1, 2, 3 pq.pop(); pq.pop(); pq.pop(); STL priority queue
  • 15. POSTECH Computer Algorithm Team Concept #include <queue> struct A { int x; } struct op { bool operator()(A a1, A a2) { return a1.x > a2.x; // 작은것부터 나옴 } }; pritority_queue<A, vector<A>, op> pq; STL priority queue
  • 16. POSTECH Computer Algorithm Team More - https://algospot.com/judge/problem/read/JOSEPHUS - https://www.acmicpc.net/problem/2504 - https://algospot.com/judge/problem/read/ITES - https://www.acmicpc.net/problem/6549