# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
798330 | Hard_slipper | Lozinke (COCI17_lozinke) | C++14 | 151 ms | 16064 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);
set<string> uniq;
for(int j = 0; j < s.size(); j++)
{
string substring = "";
for(int k = j; k < s.size(); k++)
{
substring += s[k];
//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... |