QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189835 | #2880. Letters Q and F | MaGnsi0# | WA | 0ms | 3516kb | C++17 | 2.4kb | 2023-09-27 23:47:24 | 2023-09-27 23:47:26 |
Judging History
answer
/**
* author: MaGnsi0
* created: 27.09.2023 18:36:24
**/
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx_f[8] = {0, 1, 2, 3, 4, 0, 0, 2};
const int dy_f[8] = {0, 0, 0, 0, 0, 1, 2, 1};
const int dx_q[10] = {0, 0, 0, 1, 2, 3, 4, 1, 2, 2};
const int dy_q[10] = {0, 1, 2, 2, 2, 2, 2, 0, 0, 1};
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
vector<string> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int F = 0, Q = 0;
function<void(int, int)> countF = [&](int x, int y) {
for (int i = 0; i < 8; ++i) {
int nx = x + dx_f[i];
int ny = y + dy_f[i];
if (nx < 0 || nx >= n) { return; }
if (ny < 0 || ny >= m) { return; }
if (a[nx][ny] == '.') { return; }
}
F++;
for (int i = 0; i < 8; ++i) {
int nx = x + dx_f[i];
int ny = y + dy_f[i];
a[nx][ny] = '.';
}
};
function<void(int, int)> countQ = [&](int x, int y) {
for (int i = 0; i < 10; ++i) {
int nx = x + dx_q[i];
int ny = y + dy_q[i];
if (nx < 0 || nx >= n) { return; }
if (ny < 0 || ny >= m) { return; }
if (a[nx][ny] == '.') { return; }
}
Q++;
for (int i = 0; i < 10; ++i) {
int nx = x + dx_q[i];
int ny = y + dy_q[i];
a[nx][ny] = '.';
}
};
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
countF(i, j);
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
countQ(i, j);
}
}
function<void(int, int)> dfs = [&](int x, int y) {
if (x < 0 || x >= n) { return; }
if (y < 0 || y >= m) { return; }
if (a[x][y] == '.') { return; }
a[x][y] = '.';
for (int i = 0; i < 4; ++i) {
int nx = x + dx[i];
int ny = y + dy[i];
dfs(nx, ny);
}
};
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] == '#') {
dfs(i, j);
F--, Q++;
}
}
}
cout << Q << " " << F;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
input:
5 3 ### #.# ### ..# ..#
output:
1 0
result:
ok single line: '1 0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
5 3 ### #.. ##. #.. #..
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
5 8 ###..### #.#..#.. ###..##. ..#..#.. ..#..#..
output:
1 1
result:
ok single line: '1 1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
8 8 .....### ###..#.# #.###### ###.#### #.###.## #.#.###. ..#...#. ......#.
output:
2 2
result:
ok single line: '2 2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
10 10 ....###... ....#.###. ....###... ....#.##.. ###.#.#### #.###.##.. ###.#..##. #.###..#.. #...#..#.. ....#.....
output:
1 4
result:
ok single line: '1 4'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3452kb
input:
50 50 ###..................###.......###...###.......### #.....###.........####..###....#.....#.####.####.# #####.#...######..#.###.#.###..##....####...#..### #.#...##..#.##....####..###....#.......###..##...# #.##..#...#####.###.##..#.##...#.###...##...#....# ..#####.###.##..#.#.#...#.#......#.####...
output:
80 45
result:
wrong answer 1st lines differ - expected: '66 70', found: '80 45'