Submission #530953

# Submission time Handle Problem Language Result Execution time Memory
530953 2022-02-27T08:04:26 Z Tenis0206 Trener (COCI20_trener) C++11
55 / 110
2000 ms 10712 KB
#include <bits/stdc++.h>

using namespace std;

const int Mod = 1e9 + 7;

int n,k;
int dp[1505];

string s[1505];

map<string,int> dps,fc;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int j=1; j<=k; j++)
    {
        cin>>s[j];
        ++dps[s[j]];
    }
    for(int i=2; i<=n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            dp[j] = 0;
        }
        for(int j=1; j<=k; j++)
        {
            cin>>s[j];
            fc.clear();
            for(int st=0; st<s[j].size(); st++)
            {
                string aux;
                for(int dr=st; dr<s[j].size(); dr++)
                {
                    aux.push_back(s[j][dr]);
                    if(!fc[aux])
                    {
                        dp[j] += dps[aux];
                        dp[j] %= Mod;
                    }
                    ++fc[aux];
                }
            }
        }
        dps.clear();
        for(int j=1; j<=k; j++)
        {
            dps[s[j]] += dp[j];
            dps[s[j]] %= Mod;
        }
    }
    int rez = 0;
    for(int j=1; j<=k; j++)
    {
        rez += dp[j];
        rez %= Mod;
    }
    cout<<rez<<'\n';
    return 0;
}

Compilation message

trener.cpp: In function 'int main()':
trener.cpp:34:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for(int st=0; st<s[j].size(); st++)
      |                           ~~^~~~~~~~~~~~
trener.cpp:37:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |                 for(int dr=st; dr<s[j].size(); dr++)
      |                                ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1278 ms 3572 KB Output is correct
2 Correct 1304 ms 2896 KB Output is correct
3 Correct 1283 ms 3564 KB Output is correct
4 Correct 179 ms 368 KB Output is correct
5 Correct 1083 ms 2424 KB Output is correct
6 Correct 1105 ms 2764 KB Output is correct
7 Correct 184 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1278 ms 3572 KB Output is correct
6 Correct 1304 ms 2896 KB Output is correct
7 Correct 1283 ms 3564 KB Output is correct
8 Correct 179 ms 368 KB Output is correct
9 Correct 1083 ms 2424 KB Output is correct
10 Correct 1105 ms 2764 KB Output is correct
11 Correct 184 ms 508 KB Output is correct
12 Execution timed out 2079 ms 10712 KB Time limit exceeded
13 Halted 0 ms 0 KB -