Submission #223219

# Submission time Handle Problem Language Result Execution time Memory
223219 2020-04-15T05:30:07 Z errorgorn Trener (COCI20_trener) C++14
110 / 110
139 ms 1020 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

const int MOD=1000000007;

int n,k;

map<string,ll> m[2];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin>>n>>k;
	
	m[0][""]=1;
	
	int a=0,b=1;
	for (int x=0;x<n;x++){
		for (int y=0;y<k;y++){
			string s,t1,t2;
			ll res=0;
			cin>>s;
			t1=s.substr(0,s.size()-1);
			t2=s.substr(1,s.size()-1);
			if (m[a].count(t1)) res+=m[a][t1];
			if (t1!=t2)
				if (m[a].count(t2)) res+=m[a][t2];
			m[b][s]+=res;
			m[b][s]%=MOD;
			//cout<<s<<" "<<res<<endl;
		}
		swap(a,b);
		m[b].clear();
	}
	
	ll ans=0;
	for (auto &it:m[a]){
		ans+=it.second;
	}
	
	cout<<ans%MOD<<endl;
}
# 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 10 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 10 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
# 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 10 ms 384 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Correct 11 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 113 ms 760 KB Output is correct
13 Correct 115 ms 760 KB Output is correct
14 Correct 122 ms 1020 KB Output is correct
15 Correct 114 ms 888 KB Output is correct
16 Correct 33 ms 504 KB Output is correct
17 Correct 126 ms 632 KB Output is correct
18 Correct 127 ms 760 KB Output is correct
19 Correct 139 ms 760 KB Output is correct
20 Correct 127 ms 760 KB Output is correct
21 Correct 126 ms 760 KB Output is correct
22 Correct 27 ms 384 KB Output is correct