Submission #96767

#TimeUsernameProblemLanguageResultExecution timeMemory
96767Rouge_HugoMate (COCI18_mate)C++14
100 / 100
1557 ms22008 KiB
#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 timeMemoryGrader output
Fetching results...