QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189834 | #2880. Letters Q and F | MaGnsi0# | WA | 1ms | 3512kb | C++17 | 1.8kb | 2023-09-27 23:44:50 | 2023-09-27 23:44:52 |
Judging History
answer
/**
* author: MaGnsi0
* created: 27.09.2023 18:36:24
**/
#include <bits/stdc++.h>
using namespace std;
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);
}
}
cout << Q << " " << F;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3512kb
input:
5 3 ### #.# ### ..# ..#
output:
1 0
result:
ok single line: '1 0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
5 3 ### #.. ##. #.. #..
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
5 8 ###..### #.#..#.. ###..##. ..#..#.. ..#..#..
output:
1 1
result:
ok single line: '1 1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
8 8 .....### ###..#.# #.###### ###.#### #.###.## #.#.###. ..#...#. ......#.
output:
2 2
result:
ok single line: '2 2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
10 10 ....###... ....#.###. ....###... ....#.##.. ###.#.#### #.###.##.. ###.#..##. #.###..#.. #...#..#.. ....#.....
output:
1 4
result:
ok single line: '1 4'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3448kb
input:
50 50 ###..................###.......###...###.......### #.....###.........####..###....#.....#.####.####.# #####.#...######..#.###.#.###..##....####...#..### #.#...##..#.##....####..###....#.......###..##...# #.##..#...#####.###.##..#.##...#.###...##...#....# ..#####.###.##..#.#.#...#.#......#.####...
output:
50 75
result:
wrong answer 1st lines differ - expected: '66 70', found: '50 75'