while (!q.empty())
{
int cx = q.front().first;
int cy = q.front().second;
q.pop();
**********if (visited[cx][cy] == 1)
continue;
visited[cx][cy] = 1;
sum++;
for (int i = 0; i < 4; i++)
{
int nx = cx + col[i];
int ny = cy + row[i];
if (nx >= 0 && ny >= 0 && nx < m&&ny < n&&!arr[nx][ny] && !visited[nx][ny])
q.push({ nx,ny });
}
}
혹시나해서 ****되어있는부분을 추가했더니 정답으로 뜨네요 혹시 무슨차이가있을까요...
어차피 이중포문에서 들어올때나 while문 안에 if문에서 push될때 visited값이 0인 좌표가 들어오지않나요...???
lllllllhisll 5년 전
bfs사용 했구여 틀린곳을 못찾겟어서 질문드립니다.
답이 실제답보다 조금 크게나오네요 ㅠㅠ
부탁드립니다!