# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793852 | Hard_slipper | Lozinke (COCI17_lozinke) | C++14 | 188 ms | 16228 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);
for(int j = 0; j < s.size(); j++)
{
unordered_map<string, int> tmp_substr_freq;
for(int k = j; k < s.size(); k++)
{
string substring = s.substr(j, (k-j)+1);
//cout << substring << '\n';
tmp_substr_freq[substring] = 1;
}
for(auto it : tmp_substr_freq)
{
substr_freq[it.first]++;
}
}
}
int ans = 0;
//cout << substr_freq["t"] << '\n';
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... |