QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189394#2880. Letters Q and FIsaacMoris#AC ✓1ms3708kbC++171.8kb2023-09-27 14:11:142023-09-27 14:11:15

Judging History

你现在查看的是最新测评结果

  • [2023-09-27 14:11:15]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3708kb
  • [2023-09-27 14:11:14]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 500 + 5, inf = 2e9;
int n, m;
char a[N][N];

bool checkisQ(int x, int y) {

    if (y - 2 < 0)return false;
    for (int i = 0; i < 5; i++) {
        if (a[x + i][y] != '#') return false;
    }

    for (int i = 0; i <= 2; i++) {
        for (int j = 1; j <= 2; j++) {
            if (i == 1 && j == 1 && a[x + i][y - j] == '#')return false;
            if ((i != 1 || j != 1) && a[x + i][y - j] != '#')return false;
        }
    }

    for (int i = 0; i < 5; i++) {
        a[x + i][y] = '.';
    }
    for (int i = 0; i <= 2; i++) {
        for (int j = 1; j <= 2; j++) {
            if ((i != 1 || j != 1)) {
                a[x + i][y - j] = '.';
            }
        }
    }
    return true;
}

bool checkisF(int x, int y) {

    if (y + 2 >= m)return false;
    for (int i = 0; i < 5; i++) {
        if (a[x + i][y] != '#') return false;
    }

    if (a[x][y + 1] != '#' || a[x][y + 2] != '#' || a[x + 2][y + 1] != '#')return false;

    for (int i = 0; i < 5; i++) {
        a[x + i][y] = '.';
    }
    a[x][y + 1] = a[x][y + 2] = a[x + 2][y + 1] = '.';
    return true;
}

void doWork() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int q = 0, f = 0;
    for (int j = m - 1; j - 2 >= 0; j--) {
        for (int i = 0; i + 4 < n; i++) {
            if (a[i + 1][j] == '.') {
                f += checkisF(i, j - 2);
            } else {
                q += checkisQ(i, j);
            }
        }
    }
    cout << q << " " << f;
}

int main() {
    IO
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}
 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3456kb

input:

5 3
###
#.#
###
..#
..#

output:

1 0

result:

ok single line: '1 0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3436kb

input:

5 3
###
#..
##.
#..
#..

output:

0 1

result:

ok single line: '0 1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5 8
###..###
#.#..#..
###..##.
..#..#..
..#..#..

output:

1 1

result:

ok single line: '1 1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3384kb

input:

8 8
.....###
###..#.#
#.######
###.####
#.###.##
#.#.###.
..#...#.
......#.

output:

2 2

result:

ok single line: '2 2'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

10 10
....###...
....#.###.
....###...
....#.##..
###.#.####
#.###.##..
###.#..##.
#.###..#..
#...#..#..
....#.....

output:

1 4

result:

ok single line: '1 4'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3464kb

input:

50 50
###..................###.......###...###.......###
#.....###.........####..###....#.....#.####.####.#
#####.#...######..#.###.#.###..##....####...#..###
#.#...##..#.##....####..###....#.......###..##...#
#.##..#...#####.###.##..#.##...#.###...##...#....#
..#####.###.##..#.#.#...#.#......#.####...

output:

66 70

result:

ok single line: '66 70'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

100 100
....###..###........######..###..###..........###....................................###...###......
.####....#.#..#######.##.####.#..#.#....###...#....###........###...###..###..###.####.....#.####...
.#..##...###..#.##..######.####..###.####.....######..........#..####....#.####...#..##.##...

output:

280 298

result:

ok single line: '280 298'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

300 300
...............###.###....###..###....######........###...###..###..###....###..........###..######......###....#########...............###.............###.###..###.###.........###.........###..........###....###.######.......###......###.....###...................###..###.......###............

output:

2472 2694

result:

ok single line: '2472 2694'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

5 298
.############.######..#########.######.###.######.######.######.##################.############.###..###..###..###.###.#####################.###..#########..###..###.###.######..###..###..###.######.###..###..######..###.###.###.######.###.###..######..#########.#########.######.###..###.#####...

output:

41 39

result:

ok single line: '41 39'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

299 3
###
#..
##.
#..
#..
...
...
###
#.#
###
..#
..#
...
...
...
###
#.#
###
..#
..#
...
###
#.#
###
..#
..#
###
#.#
###
..#
..#
...
###
#..
##.
#..
#..
...
...
...
###
#..
##.
#..
#..
###
#.#
###
..#
..#
...
...
###
#..
##.
#..
#..
...
...
###
#.#
###
..#
..#
###
#.#
###
..#
..#
###
#..
##.
#..
#....

output:

26 20

result:

ok single line: '26 20'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

123 234
.........###....###.###....###....###....###....###.....###.......######...........###..............###.###....###.......###...###......###........###............................###........###.......###....###...###..###..###.........
###..###.#...####.#.#.#....#.#.####.####.#.#....#..###..#...

output:

785 838

result:

ok single line: '785 838'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

234 123
.###........###.###...........###..######.............###....###...######..######................................###.......
.#.#........#.#.#.#.###..###..#....#..#.#.............#.####.#.#...#..#.#..#..#.........###..............###.###.#.#######.
.###........###.###.#.####.#####...##.###......

output:

805 836

result:

ok single line: '805 836'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3396kb

input:

5 3
...
...
...
...
...

output:

0 0

result:

ok single line: '0 0'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

300 300
.......................................................................................................................................................................................................................................................................................................

output:

0 0

result:

ok single line: '0 0'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

300 300
###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......

output:

8019 0

result:

ok single line: '8019 0'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

300 300
###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###........###......

output:

0 8019

result:

ok single line: '0 8019'