2026. 1. 21. 20:57ㆍ언리얼 7기 본캠프
와... 오늘 코드카타는 진짜 어려웠다는거 말고는 설명이 힘듬
이차원 벡터로 억지로 변환해서 만든 문제와, 굉장히 초기에 잠깐 봤던 stringstream과 unordered_set을 기억해내서 풀었던 문제가 있었음
또 입력 숫자가 많아서 시간초과가 뜰까봐 조마조마하며 풀었음
//이차원벡터 관련 문제. 좀 더 간단하게 할 수도 있었을 것 같은데...
#include <string>
#include <vector>
#include <map>
using namespace std;
vector<int> solution(vector<string> park, vector<string> routes) {
map<char,vector<int>> dir;
int x, y;
dir['E'] = {0,1};
dir['W'] = {0,-1};
dir['N'] = {-1,0};
dir['S'] = {1,0};
vector<int> answer;
int width = park[0].length();
int height = park.size();
vector<vector<int>> dim(height, vector<int>(width, 0));
for(int i = 0; i < height; i++){
for(int j = 0; j < width; j++){
switch(park[i][j]){
case 'S':
dim[i][j] = 0;
x = j;
y = i;
break;
case 'O':
dim[i][j] = 0;
break;
case 'X':
dim[i][j] = 1;
break;
}
}
}
for (string s : routes){
bool isOk = true;
int tx = x;
int ty = y;
for(int i = 0; i < stoi(s.substr(2)); i++){
if(ty + dir[s[0]][0] >= height || ty + dir[s[0]][0] < 0 ||
tx + dir[s[0]][1] >= width || tx + dir[s[0]][1] < 0){
isOk = false;
break;
}
ty += dir[s[0]][0];
tx += dir[s[0]][1];
if(dim[ty][tx] == 1){
isOk = false;
break;
}
}
if (isOk){
x = tx;
y = ty;
}
}
answer.push_back(y);
answer.push_back(x);
return answer;
}
//sstream과 unordered_set을 처음 사용한 문제. 중복을 허용하지 않는다는건 생각보다 유용할지도?
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <unordered_set>
using namespace std;
vector<int> solution(vector<string> id_list, vector<string> report, int k) {
vector<int> answer(id_list.size(),0);
map<string, int> repoCount;
map<string, unordered_set<string>> repoID;
for(string s : report){
stringstream ss(s);
string reporter;
string reported;
ss >> reporter >> reported;
if(repoID[reporter].insert(reported).second == true) repoCount[reported]++;
}
for(int i = 0; i < id_list.size(); i++){
for(string id : repoID[id_list[i]]){
if(repoCount[id] >= k) answer[i]++;
}
}
return answer;
}
오늘은 7번과제 제작을 마무리단계로 진입시킴. 전역 IMC를 만들어서 Pawn과 Drone을 왔다갔다 할수있게 만들었고, Drone의 목적에 따라 회전방향에 따른 이동을 구현했고, 추가적으로 FQuat이란걸 이용해서 특정 키를 누르면 Pitch, Roll값을 서서히 0으로 만들게 해주는 기능도 추가로 넣었음


문제의 Quat를 사용한 코드인데, 이걸 사용한 이유는 Rotator를 기준으로 Pitch, Roll을 0으로 만들려고 한다면 StableSpeed만큼 각각 돌아가게 되어서 두 수치가 동시에 0이 되지 않고 둘 중 하나만 0이 먼저 되고 다음것이 0이 되는 현상이 일어남. 그래서 두 수치를 동시에 0으로 딱 만드는 방법을 찾아보다보니 FQuat을 활용한 방법을 찾게 되었고, 원리를 대략적으로 이해한것은 점에서 점까지 최단거리가 되는 각도를 구하고 그 각으로 이동(?)해서 결과적으로 동시에 0,0이 되게 되는것...인 것 같음. 일단 모르는 코드라도 작성하면서 배우라는 튜터님의 가르침으로 일단 작성하면서 이해해보려고 하긴 했는데, 이건 진짜 이해하기 어려운 부분이 있었음...
내일은 PawnClass에 애니메이션을 빠르게 적용하고 코드 일부분만 좀 다듬어서 제출할 예정. 영상도 찍어야 한다...
'언리얼 7기 본캠프' 카테고리의 다른 글
| 260123 TIL Unreal C++ 12일차, 8번과제 (1) | 2026.01.23 |
|---|---|
| 260122 TIL - Unreal C++ 11일차, 7번과제 제출 (1) | 2026.01.22 |
| 260120 TIL - Unreal C++ 9일차 (1) | 2026.01.20 |
| 260119 TIL - Unreal C++ 8일차 (0) | 2026.01.19 |
| 260116 TIL - Unreal C++ 7일차, 6번 과제 제출 (0) | 2026.01.16 |