关于CodeForces的字符编码问题(求助)
查看原帖
关于CodeForces的字符编码问题(求助)
735387
songtj楼主2022/8/9 18:19

关于CodeForces的字符编码问题(求助)

首先贴出我的代码:\LARGE{\textbf{首先贴出我的代码:}}

#include<bits/stdc++.h>
using namespace std;
int n, m;
char a[2010][2010];
int xp[9] = {0,-1,-1,-1,0,0,1,1,1};
int yp[9] = {0,-1,0,1,-1,1,-1,0,1};

inline bool check(int x, int y) {
    if ((x<0||x>n)||(y<0||y>m)) return 0;
    if (a[x][y]=='.') return 0;
    else if (a[x-1][y-1]=='.'&&a[x][y-1]=='.'&&a[x-1][y]=='.') return 1;
    else if (a[x+1][y-1]=='.'&&a[x][y-1]=='.'&&a[x+1][y]=='.') return 1;
    else if (a[x-1][y+1]=='.'&&a[x][y+1]=='.'&&a[x-1][y]=='.') return 1;
    else if (a[x+1][y+1]=='.'&&a[x][y+1]=='.'&&a[x+1][y]=='.') return 1;
    else return 0;
}
    
inline void dfs(int x, int y) {
    if (!check(x, y)) {
        return;
    }
    else {
        a[x][y] = '.';
        for (int i = 1; i <= 8; i++) {
            dfs(x+xp[i], y+yp[i]);
        }
        return;
    }
    /*int flag = 0;
    for (int i = 1; i <= 4; i++) {
        int x_pos = x + xp[i];
        for (int j = 1; j <= 4; j++) {
            int y_pos = y + yp[j];
            if (a[x_pos][y_pos]=='.') continue;
            else flag++;
        }
        if (flag > 1) return;
        flag = 0;
    }*/
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            a[i][j] = getchar();
            if (a[i][j] == '\n') {
                a[i][j] = getchar();
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dfs(i, j);
        }
    }
    for (int i =1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

请忽略掉我的注释\large{\textbf{\textit{\textcolor{blue}{请忽略掉我的注释}}}}

当我在CodeForcesCodeForces上提交这一题时,提醒我第一个测试点出错,但当我查看测试数据时,发现程序输出的字符都变成了乱码

就像这样:

�����

图片:

于是我又把测试数据粘了下来,在本地IDE上测试了一遍,是没有问题的

对此我感到十分甚至九分不解\Large{\textbf{对此我感到\textcolor{red}{十分甚至九分不解}}}

homo独有的十退制

我猜测可能是编码的问题,我使用的是UTF-8编码,我本来是想换成ASCII编码再试一下,但我使用的VScode中的“通过编码重新保存”中并没有这个选项

十分希望哪位dalao可以给本蒟蒻解答一下疑惑,在此感谢!\Large{\textbf{十分希望哪位dalao可以给本蒟蒻解答一下疑惑,\textcolor{red}{在此感谢!}}}

2022/8/9 18:19
加载中...