結果

問題 No.3850 作門ハッカソン
コンテスト
ユーザー GOTKAKO
提出日時 2026-12-04 21:37:20
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 25 ms / 2,000 ms
+ 694µs
コード長 1,453 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,386 ms
コンパイル使用メモリ 223,444 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-12-04 21:37:24
合計ジャッジ時間 4,434 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <cassert>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while(T--){
        int H,W; cin >> H >> W;
        vector<string> S(H);
        for(auto &s : S) cin >> s;
        bool yes = false;
        for(int i=1; i<H; i++){
            string s = S.at(i-1),t = S.at(i);
            for(auto &c : s) if(c == '?') c = '#';
            s += '.';
            for(int k=0; k<W; k++){
                if(s.at(k) == '.') continue;
                int l = k,r = k;
                while(s.at(r) == '#') r++;
                r--;
                for(int p=l; p<=r; p++){
                    if(t.at(p) == '.') continue;
                    if(t.at(p) == '?') t.at(p) = '#';
                    break;
                }
                for(int p=r; p>=l; p--){
                    if(t.at(p) == '.') continue;
                    if(t.at(p) == '?') t.at(p) = '#';
                    break;
                }
                for(int p=l; p<=r; p++) if(t.at(p) == '?') t.at(p) = '.';
                vector<int> B;
                for(int p=l; p<=r; p++) if(t.at(p) == '#') B.push_back(p);
                for(int i=1; i<B.size(); i++) if(B.at(i)-B.at(i-1) > 1){yes = true; break;}
                k = r;
                if(yes) break;
            }

            if(yes) break;
        }
        if(yes) cout << "Yes\n";
        else cout << "No\n";
    }
}
0