Submission #223203

# Submission time Handle Problem Language Result Execution time Memory
223203 2020-04-15T05:06:51 Z oolimry Trener (COCI20_trener) C++14
22 / 110
76 ms 2296 KB
#include <bits/stdc++.h>

using namespace std;
long long mod = 1000000007;

inline long long add(long long a, long long b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}


unordered_map<string, long long> m;
unordered_map<string, long long> mm;

void prop(string s, long long x){
	//cout << s << " " << x << "\n";
	if(x == 0) return;
	for(char c = 'a';c <= 'z';c++){
		//cout << s+c << " " << c+s << "\n";
		mm[s+c] += x;
		if(s + c != c + s) mm[c+s] += x;
	}
}

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k; cin >> n >> k;
	
	if(n == 1){
		cout << k;
		return 0;
	}
	
	for(int j = 0;j < k;j++){
		string s; cin >> s;
		prop(s, 1);
	}
	

	
	for(int i = 2;i <= n-1;i++){
		swap(m, mm);
		mm.clear();
		for(int j = 0;j < k;j++){
			string s; cin >> s;
			prop(s, m[s]);
		}
	}
	
	long long ans = 0;
	for(int j = 0;j < k;j++){
		string s; cin >> s;
		ans = add(ans, mm[s]);
	}
	
	cout << ans;
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 1908 KB Output is correct
2 Correct 76 ms 2296 KB Output is correct
3 Correct 66 ms 2168 KB Output is correct
4 Incorrect 36 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 68 ms 1908 KB Output is correct
6 Correct 76 ms 2296 KB Output is correct
7 Correct 66 ms 2168 KB Output is correct
8 Incorrect 36 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -