백준 1987번: 알파벳 C++코드(DFS, Backtracking, 백트래킹)
#include #include using namespace std; int alphabet[26] = {0,}; char graph[21][21] = {0,}; int r,c; int result = 0; int y[4] = {0,0,-1,1}; int x[4] = {-1,1,0,0}; void dfs(int ny, int nx, int cnt){ if(result c; for(int i=0; i graph[i][j]; } } alphabet[graph[0][0]-65] = 1; dfs(0,0,1); cout