QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#599752 | #5485. MazeMan | andahe | WA | 0ms | 3696kb | C++17 | 1.6kb | 2024-09-29 10:18:30 | 2024-09-29 10:18:31 |
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>0;
}
}
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 3568kb
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: 3632kb
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: 3696kb
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'