Submission #260466

# Submission time Handle Problem Language Result Execution time Memory
260466 2020-08-10T10:42:29 Z stefantaga Cubeword (CEOI19_cubeword) C++14
0 / 100
1100 ms 19448 KB
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
struct wow
{
    int pal,lung;
    char st,dr;
}v[100005];
string s;
map <string,int> m;
int nr[15][105][105],n,i,j,t,k,z,sum,din[105][105][105];
void adds(string s)
{
    if (m[s]!=0)
    {
        return;
    }
    m[s]=1;
    nr[s.size()][s[0]][s.back()]++;
}
int main()
{
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>s;
        for (j=0;j<s.size();j++)
        {
            if ('a'<=s[j]&&s[j]<='z')
            {
                s[j]=s[j]-'a';
            }
            else
            if ('A'<=s[j]&&s[j]<='Z')
            {
                s[j]=s[j]-'A'+26;
            }
            else
            {
                s[j]=s[j]-'0'+52;
            }
        }
        adds(s);
        reverse(s.begin(),s.end());
        adds(s);
    }
    sum=0;
    for (i=3;i<=10;i++)
    {
        memset(din,0,sizeof(din));
        for (k=0;k<=61;k++)
        {
            for (t=0;t<=61;t++)
            {
                for (j=0;j<=61;j++)
                {
                    for (z=0;z<=61;z++)
                    {
                        din[t][j][z]=(din[t][j][z]+1LL*nr[i][k][t]*nr[i][k][j]*nr[i][k][z])%MOD;
                    }
                }
            }
        }
        for (k=0;k<=61;k++)
        {
            for (t=0;t<=61;t++)
            {
                for (j=0;j<=61;j++)
                {
                    for (z=0;z<=61;z++)
                    {
                        sum=(sum+1LL*din[k][t][j]*din[k][t][z]*din[k][j][z]*din[t][j][z])%MOD;
                    }
                }
            }
        }
    }
    cout<<sum;
    return 0;
}

Compilation message

cubeword.cpp: In function 'void adds(std::__cxx11::string)':
cubeword.cpp:19:22: warning: array subscript has type 'char' [-Wchar-subscripts]
     nr[s.size()][s[0]][s.back()]++;
                      ^
cubeword.cpp:19:32: warning: array subscript has type 'char' [-Wchar-subscripts]
     nr[s.size()][s[0]][s.back()]++;
                                ^
cubeword.cpp: In function 'int main()':
cubeword.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j=0;j<s.size();j++)
                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 19448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 19448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 19448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 19448 KB Time limit exceeded
2 Halted 0 ms 0 KB -