# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
524525 |
2022-02-09T12:03:11 Z |
tato |
Trener (COCI20_trener) |
C++14 |
|
2000 ms |
6264 KB |
#include <bits/stdc++.h>
using namespace std;
long long p = 1e9+7;
map <string, long long > mp;
long long pas = 0;
int n,k;
vector <string > v[51];
long long g[51][1501];
int used[51][1501];
bool check(string s, string l)
{
string t = l.substr(0,l.size() - 1);
string f = l.substr(1);
if(s == t or s == f)
return true;
else
return false;
}
long long dfs(pair <int,int> par,int m)
{
if(m == n + 1)
return 1;
used[par.first][par.second] = 1;
for(int i = 0; i < k; i++)
if(check(v[par.first][par.second], v[m][i]))
{
long long cnt;
if(used[m][i] == 1)
cnt = g[m][i];
else
cnt = dfs({m,i}, m + 1);
g[par.first][par.second] = (g[par.first][par.second] + cnt) % p;
}
return g[par.first][par.second];
}
void answer()
{
string s;
cin >> n >> k;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= k; j++)
{
cin >> s;
v[i].push_back(s);
}
for (int i = 0; i < k; i++)
pas = (dfs({1,i},2) + pas) % p;
cout << pas;
}
int main()
{
int t = 1;
//cin >> t;
while(t--)
answer();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1128 KB |
Output is correct |
2 |
Correct |
66 ms |
1128 KB |
Output is correct |
3 |
Correct |
52 ms |
1120 KB |
Output is correct |
4 |
Correct |
52 ms |
1036 KB |
Output is correct |
5 |
Correct |
50 ms |
1100 KB |
Output is correct |
6 |
Correct |
51 ms |
1100 KB |
Output is correct |
7 |
Correct |
52 ms |
1064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
49 ms |
1128 KB |
Output is correct |
6 |
Correct |
66 ms |
1128 KB |
Output is correct |
7 |
Correct |
52 ms |
1120 KB |
Output is correct |
8 |
Correct |
52 ms |
1036 KB |
Output is correct |
9 |
Correct |
50 ms |
1100 KB |
Output is correct |
10 |
Correct |
51 ms |
1100 KB |
Output is correct |
11 |
Correct |
52 ms |
1064 KB |
Output is correct |
12 |
Execution timed out |
2062 ms |
6264 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |