結果
問題 | No.1909 Detect from Substrings |
ユーザー |
![]() |
提出日時 | 2022-04-22 21:57:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,431 bytes |
コンパイル時間 | 2,045 ms |
コンパイル使用メモリ | 176,496 KB |
実行使用メモリ | 14,008 KB |
最終ジャッジ日時 | 2024-06-24 03:06:11 |
合計ジャッジ時間 | 5,667 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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); } if(se.size()>m+1){ cout << 0 << '\n'; return 0; } s = *se.begin(); se.erase(se.begin()); vector<string> p(se.begin(), se.end()); 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() && ans>=2) break; } } cout << ans << '\n'; return 0; }