結果
| 問題 | No.1909 Detect from Substrings | 
| コンテスト | |
| ユーザー |  沙耶花 | 
| 提出日時 | 2022-04-22 21:34:52 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 746 bytes | 
| コンパイル時間 | 4,998 ms | 
| コンパイル使用メモリ | 254,160 KB | 
| 最終ジャッジ日時 | 2025-01-28 20:06:06 | 
| ジャッジサーバーID (参考情報) | judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 TLE * 26 | 
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
vector<string> s;
int ans = 0;
int n,m;
void dfs(vector<int> &t,int cur){
	//cout<<cur<<endl;
	if(cur==m+1){
		ans++;
		return;
	}
	rep(i,26){
		int M = 0;
		char c = 'a';
		c += i;
		auto tt = t;
		rep(j,n){
			if((cur==m&&t[j]==0) || s[j][cur-t[j]]!=c){
				t[j]++;
				M = max(M,t[j]);
				if(M>=2)break;
			}
		}
		//cout<<cur<<','<<i<<','<<M<<endl;
		if(M<=1){
			dfs(t,cur+1);
		}
		t = tt;
	}
}
int main(){
	
	
	cin>>n>>m;
	s.resize(n);
	rep(i,n)cin>>s[i];
	
	vector<int> t(n,0);
	dfs(t,0);
	cout<<ans<<endl;
	
	return 0;
}
            
            
            
        