| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 51904 | EntityIT | Lozinke (COCI17_lozinke) | C++14 | 386 ms | 4076 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 20005;
string s[N];
map<string, int> cnt, rem;
int ans, n;
signed main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >>s[i], cnt[ s[i] ] ++;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < s[i].size(); ++j) {
            string now = "";
            for (int k = j; k < s[i].size(); ++k) {
                now += s[i][k];
                if (cnt.count(now)) {
                    ans += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                    rem[now] += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                    cnt[now] = (j == 0 && k + 1 == s[i].size() ? 1 : 0);
                }
            }
        }
        for (auto pa : rem) cnt[ pa.first ] += pa.second;
        rem.clear();
    }
    cout << ans;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
