QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#671702 | #2880. Letters Q and F | IllusionaryDominance# | AC ✓ | 1ms | 3916kb | C++20 | 2.2kb | 2024-10-24 14:07:37 | 2024-10-24 14:07:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300 + 5;
int N, M;
char str[MAX_N][MAX_N], f[MAX_N][MAX_N];
void subtract_f(int x, int y) {
str[x][y] = 0;
str[x + 1][y] = 0;
str[x + 2][y] = 0;
str[x + 3][y] = 0;
str[x + 4][y] = 0;
str[x][y + 1] = 0;
str[x][y + 2] = 0;
str[x + 2][y + 1] = 0;
}
void subtract_q(int x, int y) {
str[x][y] = 0;
str[x + 1][y] = 0;
str[x + 2][y] = 0;
str[x][y + 1] = 0;
str[x + 2][y + 1] = 0;
str[x][y + 2] = 0;
str[x + 1][y + 2] = 0;
str[x + 2][y + 2] = 0;
str[x + 3][y + 2] = 0;
str[x + 4][y + 2] = 0;
}
bool checkQ(int i, int j) {
char Q = str[i + 1][j] == '#' && str[i + 2][j] == '#' && str[i][j + 1] == '#' && str[i + 2][j + 1] == '#';
for (int k = 0; k < 5; k ++) {
if (i + k > N || str[i + k][j + 2] != '#') {Q = 0; break;}
}
return Q;
}
int main() {
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i ++) {
scanf("%s", str[i] + 1);
}
int cnt[2] = {0, 0};
for (int i = 1; i <= N; i ++) {
for (int j = 1; j <= M; j ++) {
if (str[i][j] == '#') {
char F = str[i][j + 1] == '#' && str[i][j + 2] == '#' && str[i + 2][j + 1] == '#';
for (int k = 1; k <= 4; k ++) {
if (i + k > N || str[i + k][j] != '#') {
F = 0; break;
}
}
char Q = checkQ(i, j);
assert(F || Q);
if (!(F && Q)) {
if (Q) {
cnt[0] ++;
subtract_q(i, j);
}else {
cnt[1] ++;
subtract_f(i, j);
}
}else {
if (j > 2 && checkQ(i + 3, j - 2)) {
cnt[0] ++;
subtract_q(i, j);
}else {
cnt[1] ++;
subtract_f(i, j);
}
}
}
}
}
cout << cnt[0] << ' ' << cnt[1] << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
5 3 ### #.# ### ..# ..#
output:
1 0
result:
ok single line: '1 0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
5 3 ### #.. ##. #.. #..
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
5 8 ###..### #.#..#.. ###..##. ..#..#.. ..#..#..
output:
1 1
result:
ok single line: '1 1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
8 8 .....### ###..#.# #.###### ###.#### #.###.## #.#.###. ..#...#. ......#.
output:
2 2
result:
ok single line: '2 2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
10 10 ....###... ....#.###. ....###... ....#.##.. ###.#.#### #.###.##.. ###.#..##. #.###..#.. #...#..#.. ....#.....
output:
1 4
result:
ok single line: '1 4'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
50 50 ###..................###.......###...###.......### #.....###.........####..###....#.....#.####.####.# #####.#...######..#.###.#.###..##....####...#..### #.#...##..#.##....####..###....#.......###..##...# #.##..#...#####.###.##..#.##...#.###...##...#....# ..#####.###.##..#.#.#...#.#......#.####...
output:
66 70
result:
ok single line: '66 70'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
100 100 ....###..###........######..###..###..........###....................................###...###...... .####....#.#..#######.##.####.#..#.#....###...#....###........###...###..###..###.####.....#.####... .#..##...###..#.##..######.####..###.####.....######..........#..####....#.####...#..##.##...
output:
280 298
result:
ok single line: '280 298'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
300 300 ...............###.###....###..###....######........###...###..###..###....###..........###..######......###....#########...............###.............###.###..###.###.........###.........###..........###....###.######.......###......###.....###...................###..###.......###............
output:
2472 2694
result:
ok single line: '2472 2694'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
5 298 .############.######..#########.######.###.######.######.######.##################.############.###..###..###..###.###.#####################.###..#########..###..###.###.######..###..###..###.######.###..###..######..###.###.###.######.###.###..######..#########.#########.######.###..###.#####...
output:
41 39
result:
ok single line: '41 39'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
299 3 ### #.. ##. #.. #.. ... ... ### #.# ### ..# ..# ... ... ... ### #.# ### ..# ..# ... ### #.# ### ..# ..# ### #.# ### ..# ..# ... ### #.. ##. #.. #.. ... ... ... ### #.. ##. #.. #.. ### #.# ### ..# ..# ... ... ### #.. ##. #.. #.. ... ... ### #.# ### ..# ..# ### #.# ### ..# ..# ### #.. ##. #.. #....
output:
26 20
result:
ok single line: '26 20'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
123 234 .........###....###.###....###....###....###....###.....###.......######...........###..............###.###....###.......###...###......###........###............................###........###.......###....###...###..###..###......... ###..###.#...####.#.#.#....#.#.####.####.#.#....#..###..#...
output:
785 838
result:
ok single line: '785 838'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
234 123 .###........###.###...........###..######.............###....###...######..######................................###....... .#.#........#.#.#.#.###..###..#....#..#.#.............#.####.#.#...#..#.#..#..#.........###..............###.###.#.#######. .###........###.###.#.####.#####...##.###......
output:
805 836
result:
ok single line: '805 836'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
5 3 ... ... ... ... ...
output:
0 0
result:
ok single line: '0 0'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
300 300 .......................................................................................................................................................................................................................................................................................................
output:
0 0
result:
ok single line: '0 0'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
300 300 ###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......
output:
8019 0
result:
ok single line: '8019 0'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
300 300 ###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......
output:
0 8019
result:
ok single line: '0 8019'