Submission #222236

# Submission time Handle Problem Language Result Execution time Memory
222236 2020-04-12T12:54:49 Z ngot23 Lozinke (COCI17_lozinke) C++11
100 / 100
521 ms 16888 KB
#include <bits/stdc++.h>
using namespace std;
map <string, int > ma;
int n;
string s[20005];


int main() {
    cin >> n;
    for(int i=1  ;i<=n; ++i) cin >> s[i], ++ma[s[i]];
    int ans=0;
    for(int i=1 ;i<=n ; ++i) {
        vector <string > v;
        int l=s[i].size();
        for(int leng=1 ; leng<=l ; ++leng) {
            for(int j=0 ; j+leng-1<l ; ++j) {
                string k = s[i].substr(j, leng);
                v.push_back(k);
            }
        }
        sort(v.begin(), v.end());
        v.resize(unique(v.begin(), v.end())-v.begin());
        for(string k:v) ans+=ma[k];
    }
    cout << ans-n;

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 896 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 6 ms 1024 KB Output is correct
4 Correct 6 ms 1024 KB Output is correct
5 Correct 17 ms 1408 KB Output is correct
6 Correct 28 ms 1280 KB Output is correct
7 Correct 31 ms 2040 KB Output is correct
8 Correct 46 ms 2936 KB Output is correct
9 Correct 121 ms 2808 KB Output is correct
10 Correct 226 ms 7932 KB Output is correct
11 Correct 204 ms 4728 KB Output is correct
12 Correct 521 ms 16888 KB Output is correct
13 Correct 373 ms 2936 KB Output is correct
14 Correct 378 ms 15096 KB Output is correct
15 Correct 519 ms 16568 KB Output is correct
16 Correct 399 ms 1280 KB Output is correct
17 Correct 158 ms 1280 KB Output is correct
18 Correct 115 ms 1152 KB Output is correct
19 Correct 354 ms 8696 KB Output is correct
20 Correct 202 ms 1280 KB Output is correct