結果
| 問題 | No.1909 Detect from Substrings | 
| コンテスト | |
| ユーザー |  houren | 
| 提出日時 | 2022-04-22 21:42:33 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,357 bytes | 
| コンパイル時間 | 1,857 ms | 
| コンパイル使用メモリ | 176,632 KB | 
| 実行使用メモリ | 13,760 KB | 
| 最終ジャッジ日時 | 2024-06-24 02:49:07 | 
| 合計ジャッジ時間 | 5,665 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 TLE * 1 -- * 30 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,ans = 0;
    int x;
    string s;
    cin >> n >> m;
    set<string> se;
    rep(i,n){
        cin >> s;
        se.insert(s);
    }
    s = *se.begin();
    se.erase(se.begin());
    vector<string> p(se.rbegin(), se.rend());
    rep(i,m+1){
        rep(j,26){
            bool b = true;
            for(auto &t:p){
                bool wa = false;
                rep(k,m+1){
                    if(i==k) x = 'a' + j;
                    else x = s[k-(i<k)];
                    if(x!=t[k-wa]){
                        if(!wa) wa = true;
                        else{
                            b = false;
                            break;
                        }
                    }
                }
                if(!b) break;
            }
            ans += b;
            if(p.size() && b>=2) break;
        }
    }
    cout << ans << '\n';
    return 0;
}
            
            
            
        