Submission #319718

#TimeUsernameProblemLanguageResultExecution timeMemory
319718gustasonLozinke (COCI17_lozinke)C++14
100 / 100
572 ms16604 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<string> v; map<string, int> pass; for(int i = 0; i < n; i++) { string str; cin >> str; v.push_back(str); pass[str]++; } int cnt = 0; for(int s = 0; s < n; s++) { string str = v[s]; int l = str.length(); set<string> st; st.insert(str); int curr = max(0, pass[str]-1); for(int i = 0; i < l; i++) { string sub; for(int j = i; j < l; j++) { sub += str[j]; if (st.count(sub)) continue; st.insert(sub); curr += pass[sub]; } } cnt += curr; } cout << cnt << "\n"; return 0; } //~ check for overflows
#Verdict Execution timeMemoryGrader output
Fetching results...