# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74540 | ZZangZZang | Lozinke (COCI17_lozinke) | C++17 | 1084 ms | 4076 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 <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <functional>
#include <string>
#include <set>
typedef long long ll;
using namespace std;
ll n, sol = 0;
string s[20001];
multiset<ll> ms;
ll trans(string& s)
{
ll ret = 0;
for(ll i=0; i<s.size(); i++) ret += (ll)(s[i]-'a'+1), ret *= 27;
return ret;
}
int main()
{
scanf("%lld", &n);
for(ll i=0; i<n; i++)
{
char str[20]; scanf("%s", str);
s[i] = string(str);
ms.insert(trans(s[i]));
}
for(ll k=0; k<n; k++)
{
set<ll> l;
vector<ll> v;
ll full = trans(s[k]);
for(ll i=0; i<s[k].size(); i++)
{
string tmp;
for(ll j=i; j<s[k].size(); j++)
{
tmp += s[k][j];
ll ttmp = trans(tmp);
if(l.find(ttmp) == l.end()) l.insert(ttmp), v.push_back(ttmp);
}
}
for(ll i=0; i<v.size(); i++)
{
if(v[i] == full) sol += (ll)(ms.count(v[i]) - 1);
else sol += (ll)(ms.count(v[i]));
}
}
printf("%lld", sol);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |