QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#468784#5485. MazeManEiad_Ahmed#WA 0ms3612kbC++201.4kb2024-07-09 00:47:172024-07-09 00:47:19

Judging History

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

  • [2024-07-09 00:47:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-07-09 00:47:17]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
using namespace std;

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

int n, m;
string a[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;
    cin.ignore();
    for (int i = 0; i < n; ++i) {
        getline(cin , a[i]);
    }
    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: 100
Accepted
time: 0ms
memory: 3588kb

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:

2 3

result:

ok 2 number(s): "2 3"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

3 5
XDRVX
X.X.X
XXXXX

output:

1 0

result:

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