Submission #845290

# Submission time Handle Problem Language Result Execution time Memory
845290 2023-09-06T13:00:59 Z vjudge1 Trener (COCI20_trener) C++14
0 / 110
7 ms 1628 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]]++;
    }
    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]];
            if(s1 != s2){
                mp[s2] += mp[ma[i][j]];
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += mp[ma[0][i]];
    }
    cout << ans << endl;
}
int main(){
    fast_io
    int t;
    t = 1;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1624 KB Output is correct
2 Correct 6 ms 1624 KB Output is correct
3 Correct 6 ms 1628 KB Output is correct
4 Incorrect 1 ms 856 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -