백준 19871 [백준] 1987 알파벳 c++ 지나왔던 길에 있었던 알파벳이 없는 길로 가야한다. 최대로 지날 수 있는 칸 수를 구하면 된다. 풀이 dfs + 백트래킹 지나온 알파벳인지 체크 -> visit #include using namespace std; int graph[27][27]; bool visit[26]; int R, C; int ans; void dfs(int y,int x, int cnt) { int dx[] = { 0,1,0,-1 }; int dy[] = { 1,0,-1,0 }; visit[graph[y][x]] = true; for (int i = 0; i = 0 && nx >= 0)/.. 2023. 4. 16. 이전 1 다음