QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619492#5267. Bricks in the WallMCdycWA 25ms3660kbC++202.5kb2024-10-07 14:25:292024-10-07 14:25:35

Judging History

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

  • [2024-10-07 14:25:35]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:3660kb
  • [2024-10-07 14:25:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int solve()
{
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<vector<pair<int, int>>> x(n, vector<pair<int, int>>(m));
    auto y = x;
    multiset<int> x_mx, y_mx;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (a[i][j] == '.')
            {
                int r = j;
                while (r < m && a[i][r] == '.')
                {
                    r++;
                }
                x_mx.insert(r - j);
                r--;
                for (int l = j; l <= r; l++)
                {
                    x[i][l].first = l - j;
                    x[i][l].second = r - l;
                }
                j = r;
            }
        }
    }
    for (int j = 0; j < m; j++)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i][j] == '.')
            {
                int r = i;
                while (r < n && a[r][j] == '.')
                {
                    r++;
                }
                y_mx.insert(r - i);
                r--;
                for (int l = i; l <= r; l++)
                {
                    y[l][j].first = l - i;
                    y[l][j].second = r - l;
                }
                i = r;
            }
        }
    }
    x_mx.insert(0), x_mx.insert(0);
    y_mx.insert(0), y_mx.insert(0);

    int ans = 0;
    {
        int t = 0;
        auto it = --x_mx.end();
        t += *it--;
        t += *it;
        ans = max(ans, t);
    }
    {
        int t = 0;
        auto it = --y_mx.end();
        t += *it--;
        t += *it;
        ans = max(ans, t);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (a[i][j] == '.')
            {
                ans = max(ans, x[i][j].first + x[i][j].second + y[i][j].first + 1);
                ans = max(ans, x[i][j].first + x[i][j].second + y[i][j].second + 1);
                ans = max(ans, y[i][j].first + x[i][j].second + y[i][j].second + 1);
                ans = max(ans, y[i][j].first + x[i][j].first + y[i][j].second + 1);
            }
        }
    }

    cout << ans << "\n";
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int test = 1;
    cin >> test;
    while (test--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2 2
..
..
4 5
###.#
#....
.##.#
#.#.#
2 1
.
.
2 3
###
#.#
5 4
##.#
..#.
#.#.
....
#.##

output:

4
6
2
1
7

result:

ok 5 number(s): "4 6 2 1 7"

Test #2:

score: -100
Wrong Answer
time: 25ms
memory: 3660kb

input:

10000
1 6
..#..#
5 7
#..##.#
..###.#
.####..
.##.##.
..#.#.#
1 7
#.####.
10 5
##..#
###.#
....#
#.#..
##.##
###.#
#....
##.##
...##
.....
1 2
.#
1 3
##.
7 6
####..
#####.
#...#.
..#..#
..##.#
##.#..
#..##.
5 4
..##
..#.
..##
..#.
##.#
5 6
.##..#
.#....
##.#.#
#..###
##....
1 6
.#.###
1 2
##
5 5
##.....

output:

4
7
2
9
1
1
6
8
8
2
0
5
3
4
4
8
12
4
10
12
8
5
8
3
5
8
1
6
8
4
6
12
7
4
6
2
5
6
3
10
5
5
8
3
4
4
6
8
4
8
6
6
6
4
4
13
3
3
7
7
2
8
3
6
6
4
5
5
11
6
6
6
6
6
9
1
7
7
7
3
7
3
8
10
3
5
4
7
8
5
2
7
6
4
6
2
7
4
2
5
7
10
4
8
8
8
9
8
8
6
2
9
3
9
9
7
4
6
7
8
5
6
7
9
4
8
11
5
6
4
9
2
7
2
3
7
6
7
11
7
6
12
6
12...

result:

wrong answer 12th numbers differ - expected: '6', found: '5'