結果
| 問題 | No.1909 Detect from Substrings |
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-04-22 21:48:42 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,431 bytes |
| 記録 | |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 176,340 KB |
| 実行使用メモリ | 13,752 KB |
| 最終ジャッジ日時 | 2024-06-24 02:55:24 |
| 合計ジャッジ時間 | 5,546 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.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;
}
houren