# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96767 | Rouge_Hugo | Mate (COCI18_mate) | C++14 | 1557 ms | 22008 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mod =1e9+7;
long long dp[2003][28][28],r[2003][27];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie (NULL);
string s;cin>>s;
int n=s.size();
long long sum=0;
for(int i=0;i<n;i++)
{
for(int j=n;j>1;j--)
{
sum=0;
for(int u=1;u<27;u++)
{
dp[j][u][s[i]-'0'-48]+=r[j-1][u]%mod;
sum+=r[j-1][u]%mod;
}
r[j][s[i]-'0'-48]+=sum%mod;
r[j][s[i]-'0'-48]%=mod;
}
r[1][s[i]-'0'-48]+=1;
}
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 |
---|---|---|---|---|
Fetching results... |