Submission #217478

# Submission time Handle Problem Language Result Execution time Memory
217478 2020-03-29T21:34:09 Z papa Trener (COCI20_trener) C++14
110 / 110
114 ms 20284 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//au majko sta odradi ova unordered mapa
//ekstra bas lep zadatak - uradjen
// :))))

int n;
int k;
ll sol;
ll mod;
vector<int> spusta[100005];
ll dp[100005];
vector<string> b[55];
unordered_map<string,ll> mp;
set<string> vec;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);

    cin >> n >> k;

    mod = (ll)(1e9)+7;
    sol = 0;

    for(int i=1;i<=n;i++)
    {
        for(int qq=1;qq<=k;qq++)
        {
            string s;
            cin >> s;
            if(s.size()==1) mp[s]++;
            else
            {
                string s1 = s.substr(0,i-1);
                string s2 = s.substr(1,i-1);
                if(s1!=s2) mp[s] = ((mp[s] + mp[s.substr(0,i-1)])%mod + mp[s.substr(1,i-1)])%mod;
                else mp[s] = (mp[s] + mp[s1])%mod;
                if(i==n) vec.insert(s);
            }
        }
    }

    for(string ss : vec) sol = (sol+mp[ss])%mod;

    cout << sol;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3840 KB Output is correct
2 Correct 11 ms 3840 KB Output is correct
3 Correct 11 ms 3840 KB Output is correct
4 Correct 7 ms 2816 KB Output is correct
5 Correct 10 ms 3584 KB Output is correct
6 Correct 10 ms 3584 KB Output is correct
7 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 10 ms 3840 KB Output is correct
6 Correct 11 ms 3840 KB Output is correct
7 Correct 11 ms 3840 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 10 ms 3584 KB Output is correct
10 Correct 10 ms 3584 KB Output is correct
11 Correct 7 ms 2816 KB Output is correct
12 Correct 103 ms 20280 KB Output is correct
13 Correct 110 ms 20280 KB Output is correct
14 Correct 114 ms 20280 KB Output is correct
15 Correct 100 ms 20284 KB Output is correct
16 Correct 29 ms 4608 KB Output is correct
17 Correct 72 ms 14856 KB Output is correct
18 Correct 76 ms 14980 KB Output is correct
19 Correct 89 ms 15112 KB Output is correct
20 Correct 73 ms 14984 KB Output is correct
21 Correct 73 ms 14984 KB Output is correct
22 Correct 28 ms 4600 KB Output is correct