# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319718 | gustason | Lozinke (COCI17_lozinke) | C++14 | 572 ms | 16604 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |