QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#468781#5485. MazeManEiad_Ahmed#WA 0ms3692kbC++201.5kb2024-07-09 00:42:372024-07-09 00:42:37

Judging History

你现在查看的是最新测评结果

  • [2024-07-09 00:42:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-07-09 00:42:37]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
using namespace std;

const int N = 1e3 + 5, mod = 1e9 + 7;

int n, m;
char a[N][N];
int dx[] = {0, -1, 0, 1, -1, 1, -1, 1};
int dy[] = {-1, 0, 1, 0, 1, -1, -1, 1};

bool valid(int i, int j) {
    return i >= 0 and j >= 0 and j < m and i < n and a[i][j] != 'X';
}

bool vis[N][N];
bool f;

void dfs(int i, int j) {
    vis[i][j] = true;
    f |= a[i][j] == '.';
    for (int k = 0; k < 4; ++k) {
        int x = i + dx[k], y = j + dy[k];
        if (valid(x, y) and !vis[x][y])
            dfs(x, y);
    }
}

void setAnswer(int Case) {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            f = false;
            if (!vis[i][j] and a[i][j] >= 'A' and a[i][j] <= 'Z' and a[i][j] != 'X') {
                dfs(i, j);
                ans += f;
            }
        }
    }
    int loss = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '.' and !vis[i][j])
                loss++;
        }
    }
    cout << ans << " " << loss;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int testCases = 1;
//    cin >> testCases;
    for (int i = 1; i <= testCases; i++) {
        setAnswer(i);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3692kb

input:

10 20
XXXXXXXAXXXXXXXBXXXX
X.. ..X.X...... ...X
X.XXX...X.X.XXXXXX.X
X.X.XXXXX.X.X....X.X
X.X... ...X.X.XX.X.X
X.X.X.XXXXXXX.XX.X.X
X.X.X.X...X...X....X
X.X.X.XXXXXXX.XXXX.X
X...X.X X.. ..X..X.X
XXXXXXXDXXXXXXXXCXXX

output:

3 44

result:

wrong answer 1st numbers differ - expected: '2', found: '3'