結果

問題 No.1909 Detect from Substrings
ユーザー 沙耶花沙耶花
提出日時 2022-04-22 21:31:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 4,556 ms
コンパイル使用メモリ 262,012 KB
実行使用メモリ 9,076 KB
最終ジャッジ日時 2023-09-06 07:50:46
合計ジャッジ時間 8,757 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 98 ms
4,376 KB
testcase_04 AC 12 ms
4,380 KB
testcase_05 AC 34 ms
5,424 KB
testcase_06 AC 50 ms
6,860 KB
testcase_07 AC 90 ms
9,076 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 <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]);
			}
		}
		//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;
}
0