Submission #238170

#TimeUsernameProblemLanguageResultExecution timeMemory
23817074TrAkToRLozinke (COCI17_lozinke)C++17
0 / 100
494 ms16760 KiB
#include<bits/stdc++.h>

using namespace std;

map < string, int > cnt;
string s[20005];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    sort(s + 1, s + n + 1, [](string f, string t) {
        return (int)f.size() > (int)t.size();
    });
    for (int i = 1; i <= n; ++i) {
        set < string > Q;
        ans += cnt[s[i]];
        for (int j = 0; j < (int)s[i].size(); ++j) {
            string t = "";
            for (int pos = j; pos < (int)s[i].size(); ++pos) {
                t += s[i][pos];
                Q.insert(t);
            }
        }
        for (auto key : Q) cnt[key]++;
    }
    cout << ans << '\n';
    return 0;
}

Compilation message (stderr)

lozinke.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...