QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189695 | #2880. Letters Q and F | Beevo# | AC ✓ | 2ms | 3680kb | C++20 | 2.1kb | 2023-09-27 19:43:43 | 2023-09-27 19:43:44 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300 + 5;
int n, m;
bool vis[N][N];
int dxF[] = {-1, -1, 0, 0, -1, -1, 0, 0};
int dyF[] = {0, 0, 1, -1, 0, 0, 1, 1};
int dxQ[] = {-1, -1, -1, -1, 0, 0, 1, 1, 0};
int dyQ[] = {0, 0, 0, 0, -1, -1, 0, 0, 1};
bool valid(int x, int y) {
return x >= 0 && x < n && y >= 0 && y < m;
}
void testCase() {
cin >> n >> m;
char g[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
cin >> g[i][j];
}
int a = 0, b = 0;
for (int i = n - 1; i >= 0; i--) {
for (int j = 0; j < m; j++) {
if (g[i][j] == '.' || vis[i][j])
continue;
int x = i, y = j;
for (int k = 0; k < 9; k++) {
x += dxQ[k], y += dyQ[k];
if (!valid(x, y) || g[x][y] == '.' || vis[x][y])
break;
}
if (valid(x, y) && g[x][y] == '#' && !vis[x][y]) {
a++;
x = i, y = j;
vis[x][y] = 1;
for (int k = 0; k < 9; k++) {
x += dxQ[k], y += dyQ[k];
vis[x][y] = 1;
}
}
x = i, y = j;
for (int k = 0; k < 8; k++) {
x += dxF[k], y += dyF[k];
if (!valid(x, y) || g[x][y] == '.' || vis[x][y])
break;
}
if (valid(x, y) && g[x][y] == '#' && !vis[x][y]) {
b++;
x = i, y = j;
vis[x][y] = 1;
for (int k = 0; k < 8; k++) {
x += dxF[k], y += dyF[k];
vis[x][y] = 1;
}
}
}
}
cout << a << ' ' << b;
}
signed main() {
Beevo
int t = 1;
// cin >> t;
while (t--)
testCase();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3448kb
input:
5 3 ### #.# ### ..# ..#
output:
1 0
result:
ok single line: '1 0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
5 3 ### #.. ##. #.. #..
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
5 8 ###..### #.#..#.. ###..##. ..#..#.. ..#..#..
output:
1 1
result:
ok single line: '1 1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
8 8 .....### ###..#.# #.###### ###.#### #.###.## #.#.###. ..#...#. ......#.
output:
2 2
result:
ok single line: '2 2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
10 10 ....###... ....#.###. ....###... ....#.##.. ###.#.#### #.###.##.. ###.#..##. #.###..#.. #...#..#.. ....#.....
output:
1 4
result:
ok single line: '1 4'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
50 50 ###..................###.......###...###.......### #.....###.........####..###....#.....#.####.####.# #####.#...######..#.###.#.###..##....####...#..### #.#...##..#.##....####..###....#.......###..##...# #.##..#...#####.###.##..#.##...#.###...##...#....# ..#####.###.##..#.#.#...#.#......#.####...
output:
66 70
result:
ok single line: '66 70'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
100 100 ....###..###........######..###..###..........###....................................###...###...... .####....#.#..#######.##.####.#..#.#....###...#....###........###...###..###..###.####.....#.####... .#..##...###..#.##..######.####..###.####.....######..........#..####....#.####...#..##.##...
output:
280 298
result:
ok single line: '280 298'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
300 300 ...............###.###....###..###....######........###...###..###..###....###..........###..######......###....#########...............###.............###.###..###.###.........###.........###..........###....###.######.......###......###.....###...................###..###.......###............
output:
2472 2694
result:
ok single line: '2472 2694'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
5 298 .############.######..#########.######.###.######.######.######.##################.############.###..###..###..###.###.#####################.###..#########..###..###.###.######..###..###..###.######.###..###..######..###.###.###.######.###.###..######..#########.#########.######.###..###.#####...
output:
41 39
result:
ok single line: '41 39'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
299 3 ### #.. ##. #.. #.. ... ... ### #.# ### ..# ..# ... ... ... ### #.# ### ..# ..# ... ### #.# ### ..# ..# ### #.# ### ..# ..# ... ### #.. ##. #.. #.. ... ... ... ### #.. ##. #.. #.. ### #.# ### ..# ..# ... ... ### #.. ##. #.. #.. ... ... ### #.# ### ..# ..# ### #.# ### ..# ..# ### #.. ##. #.. #....
output:
26 20
result:
ok single line: '26 20'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
123 234 .........###....###.###....###....###....###....###.....###.......######...........###..............###.###....###.......###...###......###........###............................###........###.......###....###...###..###..###......... ###..###.#...####.#.#.#....#.#.####.####.#.#....#..###..#...
output:
785 838
result:
ok single line: '785 838'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
234 123 .###........###.###...........###..######.............###....###...######..######................................###....... .#.#........#.#.#.#.###..###..#....#..#.#.............#.####.#.#...#..#.#..#..#.........###..............###.###.#.#######. .###........###.###.#.####.#####...##.###......
output:
805 836
result:
ok single line: '805 836'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
5 3 ... ... ... ... ...
output:
0 0
result:
ok single line: '0 0'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
300 300 .......................................................................................................................................................................................................................................................................................................
output:
0 0
result:
ok single line: '0 0'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
300 300 ###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......
output:
8019 0
result:
ok single line: '8019 0'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
300 300 ###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......
output:
0 8019
result:
ok single line: '0 8019'