結果

問題 No.1909 Detect from Substrings
ユーザー hourenhouren
提出日時 2022-04-22 21:40:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,317 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 173,932 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-06 08:00:42
合計ジャッジ時間 5,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 5 ms
5,184 KB
testcase_07 AC 6 ms
5,232 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

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