結果

問題 No.2456 Stamp Art
ユーザー hiro71687khiro71687k
提出日時 2023-09-01 22:42:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,314 bytes
コンパイル時間 4,232 ms
コンパイル使用メモリ 266,544 KB
実行使用メモリ 71,180 KB
最終ジャッジ日時 2023-09-02 11:18:57
合計ジャッジ時間 9,940 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 225 ms
7,512 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 224 ms
7,600 KB
testcase_07 AC 278 ms
71,180 KB
testcase_08 AC 385 ms
39,200 KB
testcase_09 AC 433 ms
25,408 KB
testcase_10 AC 231 ms
8,036 KB
testcase_11 AC 231 ms
8,128 KB
testcase_12 AC 290 ms
7,852 KB
testcase_13 AC 225 ms
7,600 KB
testcase_14 AC 228 ms
7,628 KB
testcase_15 AC 226 ms
7,552 KB
testcase_16 AC 120 ms
5,648 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 151 ms
6,328 KB
testcase_20 AC 225 ms
7,584 KB
testcase_21 AC 286 ms
34,744 KB
testcase_22 AC 318 ms
27,592 KB
testcase_23 AC 13 ms
4,376 KB
testcase_24 AC 23 ms
4,376 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=100990999999999909;
int main(){
    ll h,w;
    cin >> h >> w;
    vector<vector<char>>s(h+2,vector<char>(w+2,'.'));
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w; j++)
        {
            cin >> s[i+1][j+1];
        }
    }
    vector<vector<ll>>hh(h+2),ww(w+2);
    for (ll i = 1; i <=h; i++)
    {
        for (ll j = 0; j <=w+1; j++)
        {
            if (s[i][j]=='.')
            {
                hh[i].push_back(j);
            }
        }
    }
    for (ll i = 1; i <=w; i++)
    {
        for (ll j = 0; j <=h+1; j++)
        {
            if (s[j][i]=='.')
            {
                ww[i].push_back(j);
            }
        }
    }
    ll ans=inf;
    for (ll i = 1; i <=h; i++)
    {
        for (ll j = 1; j <=w; j++)
        {
            if (s[i][j]=='#')
            {
                ll v=lower_bound(hh[i].begin(),hh[i].end(),j)-hh[i].begin();
                ans=min(ans,hh[i][v]-hh[i][v-1]-1);
                v=lower_bound(ww[j].begin(),ww[j].end(),i)-ww[j].begin();
                ans=min(ans,ww[j][v]-ww[j][v-1]-1);
            }
        }
    }
    cout << ans << endl;
}
0