어제 하던 과제 좀 더 컨텐츠 늘리기
적절한 스태틱메시를 찾아서 JumpOrb를 변경해주었다.




스태틱메시는 동전같이 생긴게 있길래 이걸로 정했다.

기존에 killzone을 만들때 bp_gamemode를 만들어 놓은것이 있어서 그것을 활용하고자 하였다.

현재 게임모드의 이벤트 그래프는 이렇게 되어있는데, savepoint를 먹었을때 respawn location에 set만 해주면 되었다.



이렇게 흩어져있는 발판들을 앞의 버튼처럼생긴 발판을 누르면 한데 모이게끔 구현하려고 했다.









내부적으로 힙 사용
삽입, 삭제 O(log N), top()은 O(1)
가장 큰/작은 원소를 추출해야하는 문제에서 효율적
특정 기준으로 우선순위를 부여하고 싶다면 사용자 정의 함수를 넣어줄 수 있다.
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct Student
{
string name;
int score;
};
struct Compare
{
bool operator()(const Student& a, const Student& b)
{
return a.score < b.score;
}
};
int main()
{
priority_queue<Student, vector<Student>, Compare> pq;
pq.push({ "tom", 95 });
pq.push({ "goong", 80 });
pq.push({ "rtan", 99 });
return 0;
}
지금 예시에서 우선순위큐의 첫번째인자, 두번째 인자인 vector의 타입으로 구조체가 들어갔는데 이런식으로 사용할 수 있는건지?
struct Compare {
bool operator()(const Student &a, const Student &b) {
return a.score < b.score;
}
};
...
.....
priority_queue<Student, vector<Student>, Compare> pq;
세번째 인자에 구조체가 들어있고 operator()(..) 이라는 특이한 구조인데 어떤 의미인지?
#include <iostream>
#include <queue>
using namespace std;
struct CompareStruct {
bool operator()(int& a, int& b)
{
return a > b;
}
};
int main()
{
priority_queue<int, vector<int>, CompareStruct> pq;
pq.push(1);
pq.push(2);
pq.push(3);
pq.push(4);
pq.push(5);
cout << "최소힙으로 정렬 되었는지 : " << pq.top() << endl;
return 0;
}
vector<int> v = {1, 2, 3};
do{
for (int x : v) cout << x << " ";
cout << endl;
} while (next_permutation(v.begin(), v.end()));
// 모든 순열을 구할 수 있음
// do while문을 통해서 다음 순열이 존재한다면 출력
Q. 거꾸로 출력
// vector<int> v = { 3, 2, 1 };
vector<int> v = {1, 2, 3};
sort(v.begin(), v.end(), greater<int>());
do {
for (int x : v) cout << x << " ";
cout << endl;
} while (prev_permutation(v.begin(), v.end()));
return 0;
vector<int> v = {9, 1, 4, 7, 2, 6};
nth_element(v.begin(), v.begin()+2, v.end());
cout << "3번째로 작은 원소 : " << v[2] << endl;
Q. 배열크기가 홀수 일때 중간 값을 찾는것을 nth_element코드 하나만으로 구현
nth_element(v.begin(), v.begin() + v.size()/2, v.end());
Q1. 배열 {15, 3, 9, 8, 5, 2, 10, 7, 6}에서 짝수만 고려하여 3번째로 큰 수를 출력하세요. (10분)
Q2. 배열 {1, 2, 3, 4}에서 길이가 3인 순열을 모두 출력하세요. 단, 순열의 첫 번째 원소는 항상 1이어야 합니다.(10분)
Q3. 배열 {4, 1, 7, 3, 8, 5}를 5 이상의 값만 내림차순으로 출력하세요. (10분)