Submission #147088

# Submission time Handle Problem Language Result Execution time Memory
147088 2019-08-27T13:26:32 Z SeekingOblivion Mate (COCI18_mate) C++14
30 / 100
2000 ms 27868 KB
//#include<fstream>
#include<queue>
#include<iostream>
#include<algorithm>
#define mod 1000000007
#define fin cin
#define fout cout
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
char c[2010],a,b;
int q,i,j,n,l,s,v[2010][2010],d[2010][26],sol[2010][26][26];
int main()
{
    fin>>c;
    for(i=0;c[i]!=0;i++);n=i;
    for(i=n-1;i>=0;i--) for(j=i+1;j<=n-1;j++) d[i][c[j]-'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=0;i<n;i++)
            for(j=0;j<='z'-'a';j++)
                if(i>=s-2)
                {
                    sol[s][c[i]-'a'][j]+=(v[i][s-2]*d[i][j])%mod;
                    if(sol[s][c[i]-'a'][j]>=mod) sol[s][c[i]-'a'][j]-=mod;
                }
    fin>>q;
    for(i=1;i<=q;i++)
    {
        fin>>l;
        fin>>a>>b;
        fout<<sol[l][a-'a'][b-'a']<<"\n";
    }
    return 0;
}


Compilation message

mate.cpp: In function 'int main()':
mate.cpp:16:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=0;c[i]!=0;i++);n=i;
     ^~~
mate.cpp:16: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;
                          ^
# Verdict Execution time Memory Grader output
1 Correct 89 ms 888 KB Output is correct
2 Correct 60 ms 760 KB Output is correct
3 Correct 70 ms 1016 KB Output is correct
4 Incorrect 117 ms 1016 KB Output isn't correct
5 Incorrect 429 ms 3552 KB Output isn't correct
6 Incorrect 484 ms 3896 KB Output isn't correct
7 Incorrect 368 ms 3392 KB Output isn't correct
8 Incorrect 336 ms 3192 KB Output isn't correct
9 Execution timed out 2041 ms 27308 KB Time limit exceeded
10 Execution timed out 2031 ms 27868 KB Time limit exceeded