| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 798314 | Hard_slipper | Lozinke (COCI17_lozinke) | C++17 | 148 ms | 16212 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
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1; //cin >> T;
    int ot = T;
    while(T--)
    {
        int n; cin >> n;
        unordered_map<string, int> substr_freq;
        vector<string> strs;
        for(int i = 0; i < n; i++)
        {
            string s; cin >> s;
            strs.push_back(s);
            for(int j = 0; j < s.size(); j++)
            {
                set<string> uniq;
                for(int k = j; k < s.size(); k++)
                {
                    string substring = s.substr(j, (k-j)+1);
                    //cout << substring << '\n';
                    uniq.insert(substring);
                }
                for(auto it : uniq)
                {
                    substr_freq[it]++;
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            ans += substr_freq[strs[i]]-1;
        }
        cout << ans << '\n';
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
