Submission #845309

# Submission time Handle Problem Language Result Execution time Memory
845309 2023-09-06T13:07:33 Z vjudge1 Trener (COCI20_trener) C++14
110 / 110
189 ms 22624 KB
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 2e5 + 5;
inline void solve(){
    int n, k;
    cin >> n >> k;
    map<string, int> mp;
    string ma[n][k];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> ma[i][j];
        }
    }
    for(int i = 0; i < k; i++){
        mp[ma[n-1][i]] = 1;
    }
    for(int i = n-1; i > 0; i--){
        for(int j = 0; j < k; j++){
            string s1 = ma[i][j].substr(0, i), s2 = ma[i][j].substr(1, i);
            mp[s1] = (mp[ma[i][j]] + mp[s1]) % MOD;
            if(s1 != s2){
                mp[s2] = (mp[s2] + mp[ma[i][j]]) % MOD;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans = (ans + mp[ma[0][i]]) % MOD;
    }
    cout << ans << endl;
}
int main(){
    fast_io
    int t;
    t = 1;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1624 KB Output is correct
2 Correct 7 ms 1624 KB Output is correct
3 Correct 7 ms 1628 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 6 ms 1624 KB Output is correct
6 Correct 6 ms 1628 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 1624 KB Output is correct
6 Correct 7 ms 1624 KB Output is correct
7 Correct 7 ms 1628 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 6 ms 1624 KB Output is correct
10 Correct 6 ms 1628 KB Output is correct
11 Correct 3 ms 860 KB Output is correct
12 Correct 162 ms 22612 KB Output is correct
13 Correct 178 ms 22608 KB Output is correct
14 Correct 184 ms 22544 KB Output is correct
15 Correct 189 ms 22624 KB Output is correct
16 Correct 20 ms 6728 KB Output is correct
17 Correct 126 ms 17244 KB Output is correct
18 Correct 127 ms 17492 KB Output is correct
19 Correct 128 ms 17320 KB Output is correct
20 Correct 130 ms 17256 KB Output is correct
21 Correct 129 ms 17400 KB Output is correct
22 Correct 22 ms 6752 KB Output is correct