WA + RE,应该又是关于字符输入的问题

P1683 入门

@[thehanged](/user/638272) ```cpp #include <iostream> using namespace std; const int N = 25; bool st[N][N]; char map[N][N]; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; int n, m, ans = 1; void dfs(int x, int y){ st[x][y] = true; for(int i = 0; i < 4; ++ i){ int tx = x + dx[i], ty = y + dy[i]; if(tx <= 0 || tx > n || ty <= 0 || ty > m) continue; if(map[tx][ty] == '.' && !st[tx][ty]){ // 可以走的地方 ans ++; dfs(tx, ty); } } } int main(){ scanf("%d %d", &m, &n); int x, y; for(int i = 1; i <= n; ++ i){ for(int j = 1; j <= m; ++ j){ std::cin>>map[i][j]; if(map[i][j] == '@') x = i, y = j; } } dfs(x, y); printf("%d", ans); // for(int i = 1; i <= n; ++ i){ // for(int j = 1; j <= m; ++ j){ // putchar(map[i][j]); // } // puts(""); // } return 0; } ``` 这样就可以过了
by nightwatch_ryan @ 2024-04-25 22:22:12


<https://www.luogu.com.cn/paste/cb7doh5c>
by Terrible @ 2024-04-25 22:45:48


@[Terrible](/user/195942) 猜到了,洛谷没有进行特殊处理,一般来说评测机全部都是LF(Linux),洛谷不仅有CR还有CRLF,这真的太无语了
by thehanged @ 2024-04-26 12:20:48


|