![article thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FsyRRr%2FbtrWGeUB13u%2FHxzuRumJperQK7mazOdVkK%2Fimg.png)
Level 0. 캐릭터의 좌표
자료구조 & 알고리즘/프로그래머스
2023. 1. 19. 08:40
Level 0. 캐릭터의 좌표 #include #include #include using namespace std; vector solution(vector keyinput, vector board) { map mp = {{"left", {-1, 0}}, {"right", {1, 0}}, {"up", {0, 1}}, {"down", {0, -1}}}; vector answer = {0, 0}; vector limit = {board[0] / 2, board[1] / 2}; for (string key : keyinput) { answer[0] = max(-limit[0], min(answer[0] + mp[key][0], limit[0])); answer[1] = max(-limit[1], min(ans..