#include #include #include typedef struct { int x, y, distance; bool break_block; } Node; int main() { int N, M; scanf("%d %d", &N, &M); int** map = (int**)malloc(sizeof(int*)*N); bool*** visited = (bool***)malloc(sizeof(bool**)*N); for(int i=0; i=M || ny<0 || ny>=N) continue; bool isWall = map[ny][nx] == 1; if(isWall && isBreakBlock) continue; bool next_block_state = isWall || isBreakBlock; // (isWall && !isBreakBlock) || isBreakBlock을 단순화한 값 int block_state_index = next_block_state ? 1 : 0; if(!visited[ny][nx][block_state_index]) { Node next = {nx, ny, nd, next_block_state}; qu[rear++] = next; visited[ny][nx][block_state_index] = true; } } } printf("%d\n",result); for(int i=0; i