Submission #238172

#TimeUsernameProblemLanguageResultExecution timeMemory
23817274TrAkToRLozinke (COCI17_lozinke)C++17
100 / 100
548 ms17504 KiB
#include<bits/stdc++.h> using namespace std; map < string, int > cnt, d; 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]++; d[s[i]]++; } for (auto key : d) ans += key.second * (key.second - 1) / 2; 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...