結果

問題 No.1909 Detect from Substrings
ユーザー hourenhouren
提出日時 2022-04-22 21:40:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,317 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 176,732 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2024-06-24 02:45:58
合計ジャッジ時間 5,802 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
        }
    }
    cout << ans << '\n';
    return 0;
}
0