結果

問題 No.86 TVザッピング(2)
ユーザー kroton
提出日時 2014-12-05 01:47:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 942 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 63,112 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-20 13:57:25
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

string mat[111];
int main(){
    int H, W;
    cin >> H >> W;
    for(int y=0;y<H;y++)cin >> mat[y];
    
    int top = 111, bot = -1, lef = 111, rig = -1;
    int tot = 0;
    
    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++)if(mat[y][x] == '.'){
            top = min(top, y);
            bot = max(bot, y);
            lef = min(lef, x);
            rig = max(rig, x);
            
            ++tot;
        }
    }
    
    int kado = 0;
    if(mat[top][lef] == '.')++kado;
    if(mat[top][rig] == '.')++kado;
    if(mat[bot][lef] == '.')++kado;
    if(mat[bot][rig] == '.')++kado;
    
    if(kado >= 3 && bot - top >= 1 && rig - lef >= 1){
        int cnt = (bot - top + 1) * 2 + (rig - lef + 1) * 2 - 4;
        if(cnt == tot){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    return 0;
}
0