# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730942 | TheSahib | Lozinke (COCI17_lozinke) | C++14 | 235 ms | 13644 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>
#define ll long long
#define pii pair<int, int>
const int oo = int(1e9) + 9;
using namespace std;
int n;
string arr[20006];
ll hashs[20006];
map<ll, int> mp;
int main(){
cin >> n;
for (int i = 0; i < n; ++i)
{
string s; cin >> s;
arr[i] = s;
set<ll> st;
for (int j = 0; j < s.size(); ++j)
{
ll h = 0;
for (int k = j; k < s.size(); k++)
{
h = (h * 26) + s[k] - 'a' + 1;
st.insert(h);
if(j == 0 && k == s.size() - 1){
hashs[i] = h;
}
}
}
for(auto& a:st){
mp[a]++;
}
}
ll ans = 0;
for (int i = 0; i < n; i++)
{
ans += mp[hashs[i]] - 1;
}
cout << ans << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |