QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#468784 | #5485. MazeMan | Eiad_Ahmed# | WA | 0ms | 3612kb | C++20 | 1.4kb | 2024-07-09 00:47:17 | 2024-07-09 00:47:19 |
Judging History
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;
}
詳細信息
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'