# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
96679 |
2019-02-10T19:40: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()
{
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 |
77 ms |
632 KB |
Output is correct |
2 |
Correct |
51 ms |
632 KB |
Output is correct |
3 |
Correct |
62 ms |
632 KB |
Output is correct |
4 |
Correct |
69 ms |
760 KB |
Output is correct |
5 |
Correct |
407 ms |
2716 KB |
Output is correct |
6 |
Correct |
427 ms |
3064 KB |
Output is correct |
7 |
Correct |
378 ms |
2552 KB |
Output is correct |
8 |
Correct |
367 ms |
2276 KB |
Output is correct |
9 |
Execution timed out |
2068 ms |
6520 KB |
Time limit exceeded |
10 |
Execution timed out |
2069 ms |
6392 KB |
Time limit exceeded |