QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#599740 | #5485. MazeMan | andahe | WA | 0ms | 3612kb | C++17 | 1.6kb | 2024-09-29 10:09:39 | 2024-09-29 10:09:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
char mp[105][105];
bool eat[105][105], door;
void goeat(int x, int y)
{
eat[x][y] = 1;
pair<int, int>to[4];
to[0].fi = x+1, to[0].se = y;
to[1].fi = x, to[1].se = y+1;
to[2].fi = x-1, to[2].se = y;
to[3].fi = x, to[3].se = y-1;
for(int i = 0; i < 4; ++i)
{
int x1 = to[i].fi, y1 = to[i].se;
if(mp[x1][y1] != 'X' && mp[x1][y1] != '.' && mp[x1][y1] != ' ') door = 1;
if((mp[x1][y1] == '.' || mp[x1][y1] == ' ')&& !eat[x1][y1]) goeat(x1, y1);
}
}
void goclear(int x, int y)
{
eat[x][y] = 0;
pair<int, int>to[4];
to[0].fi = x+1, to[0].se = y;
to[1].fi = x, to[1].se = y+1;
to[2].fi = x-1, to[2].se = y;
to[3].fi = x, to[3].se = y-1;
for(int i = 0; i < 4; ++i)
{
int x1 = to[i].fi, y1 = to[i].se;
if(mp[x1][y1] == '.' && eat[x1][y1]) goclear(x1, y1);
}
}
int main()
{
//freopen("1.in","r",stdin);
int n, m; cin >> n >> m;
getchar();
for(int i = 1; i <= n; ++i, getchar())
for(int j = 1; j <= m; ++j) mp[i][j] = getchar();
int people = 0;
for(int i = 2; i <= n-1; ++i)
for(int j = 2; j <= m-1; ++j)
{
if(!eat[i][j] && mp[i][j] == '.') {
door = 0;
goeat(i, j);
if(!door) goclear(i, j);
people += door;
}
}
int res = 0;
for(int i = 2; i <= n-1; ++i)
for(int j = 2; j <= m-1; ++j)
if(!eat[i][j] && mp[i][j] == '.') res++;
cout<<people<<" "<<res<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
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: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 5 XDRVX X.X.X XXXXX
output:
2 0
result:
ok 2 number(s): "2 0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 5 NAQXX X X.X XXXXX
output:
0 1
result:
ok 2 number(s): "0 1"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
10 68 XXXXXXPXXXXXXXXCXXXXXXXXXXXXXXXXXXXXHXXXXXXXXXXXXXXIXXRXXXXXXXXXKXXX X.XX..XXXX.X.X.XXXXXX..XXXXX.X.X......X ......X.X.. X.....XXX.. X.X X X.X.XXX.. X..X..X ..X..XX.XX.XXXXX.X....X.X.X.XXXX.X. X..X.X.....X X.X..XX .XX..X....X.XX.X..XXX....X.X. .X....X.X .XX.X...X.XXX.. X..X X.X..X..XXXXXX .. ...
output:
4 69
result:
wrong answer 2nd numbers differ - expected: '116', found: '69'