백준 20166 문자열 지옥에 빠진 호석 혼내주기
제 1회 류호석배 알고리즘 코딩 테스트 문제. dfs + dp인데 범위를 벗어나면 반대쪽에서 이어지도록 하면 된다. dp에는 위치정보(x, y)와 문자의 index값을 넣으면 된다. #include #include #include using namespace std; int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0}; int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; int cache[10][10][5]; // x y idx char map[10][10]; int n, m; string s; int d(int x, int y, int idx, int len){ if(idx == len) return 1; int& ret = cache[x][y][idx]; if..
혼내주기
2021. 8. 1. 23:19