# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
96681 |
2019-02-10T19:43:21 Z |
Rouge_Hugo |
Mate (COCI18_mate) |
C++14 |
|
2000 ms |
6520 KB |
#include <bits/stdc++.h>
using namespace std;
const int mod =1e9+7;
int dp[2003][28][28];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie (NULL);
string s;cin>>s;
int n=s.size();
for(int i=0;i<n;i++)
{
for(int j=n;j>2;j--)
{
for(int u=1;u<=26;u++)
{
for(int h=1;h<27;h++)
{
dp[j][u][s[i]-'0'-48]+=dp[j-1][h][u]%mod;
dp[j][u][s[i]-'0'-48]%=mod;
}
}
}
for(int j=1;j<=26;j++)
{
dp[2][j][s[i]-'0'-48]+=dp[1][0][j];
dp[2][j][s[i]-'0'-48]%=mod;
}
dp[1][0][s[i]-'0'-48]++;
}
char c,c1;
int x;
int q;cin>>q;
while (q--)
{
cin>>x;
cin>>c>>c1;
cout<<dp[x][c-'0'-48][c1-'0'-48]%mod<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
632 KB |
Output is correct |
2 |
Correct |
47 ms |
632 KB |
Output is correct |
3 |
Correct |
38 ms |
504 KB |
Output is correct |
4 |
Correct |
60 ms |
632 KB |
Output is correct |
5 |
Correct |
372 ms |
1936 KB |
Output is correct |
6 |
Correct |
395 ms |
2040 KB |
Output is correct |
7 |
Correct |
410 ms |
1828 KB |
Output is correct |
8 |
Correct |
328 ms |
1784 KB |
Output is correct |
9 |
Execution timed out |
2056 ms |
6396 KB |
Time limit exceeded |
10 |
Execution timed out |
2061 ms |
6520 KB |
Time limit exceeded |