Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 输出重定向未注释，贡献四个WA

Posted by Matthew_lyns at 2017-04-21 17:22:21 on Problem 1979
```#include <iostream>

#define M  20 + 10
#define N  20 + 10
using namespace std;

int m, n;
int count;
char map[M][N];
int dir[4][2] = {{-1, 0},{1, 0},{0, 1},{0, -1}};

void dfs(int x, int y)
{
int newx, newy;

map[x][y] = '#';
for(int i = 0; i < 4; i++)
{
newx = x + dir[i][0];
newy = y + dir[i][1];
if(newx >= 0 && newx < n && newy >= 0 && newy < m && map[newx][newy] == '.')
{
count ++;
dfs(newx, newy);
}
}
}

int main()
{
int x = 0, y = 0;
int result = 0;
//freopen("input.txt","r",stdin);

while(scanf("%d%d", &m, &n) != EOF && m && n)
{
memset(map, 0, sizeof(map));
count = 1;

for(int i = 0; i < n; i++)
{
scanf("%s", &map[i]);
}

for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(map[i][j]== '@'){
x = i;
y = j;
map[x][y] = '.';
}
}
}
dfs(x, y);
result = count;
cout <<result<<endl;
}
return 0;
}```

Followed by: