Submission #147117

#TimeUsernameProblemLanguageResultExecution timeMemory
147117SeekingOblivionMate (COCI18_mate)C++14
100 / 100
444 ms24728 KiB
#include<cstdio> #include<queue> #include<algorithm> #define mod 1000000007 using namespace std; char c[2010],a[2]; int q,i,j,n,l,s,v[2010][2010],d[2010][26],sol[2010][26][26],f[26]; int main() { scanf("%s",c); for(i=0;c[i]!=0;i++);n=i; for(i=n-1;i>=0;i--) { for(j=0;j<='z'-'a';j++) d[i][j]=f[j]; f[c[i]-'a']++; } for(i=0;i<=n;i++) { v[i][0]=1; for(j=1;j<=i;j++) { v[i][j]=v[i-1][j]+v[i-1][j-1]; if(v[i][j]>=mod) v[i][j]-=mod; } } for(s=2;s<=n;s++) for(i=s-2;i<n;i++) for(j=0;j<='z'-'a';j++) { sol[s][c[i]-'a'][j]+=(1LL*v[i][s-2]*d[i][j])%mod; if(sol[s][c[i]-'a'][j]>=mod) sol[s][c[i]-'a'][j]-=mod; } scanf("%d",&q); for(i=1;i<=q;i++) { scanf("%d%s",&l,a); printf( "%d\n",sol[l][a[0]-'a'][a[1]-'a']); } return 0; }

Compilation message (stderr)

mate.cpp: In function 'int main()':
mate.cpp:11:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=0;c[i]!=0;i++);n=i;
     ^~~
mate.cpp:11:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(i=0;c[i]!=0;i++);n=i;
                          ^
mate.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",c);
     ~~~~~^~~~~~~~
mate.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
     ~~~~~^~~~~~~~~
mate.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%s",&l,a);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...