# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116818 | tuanasanh | Lozinke (COCI17_lozinke) | C++17 | 562 ms | 16488 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>
#pragma O3
using namespace std;
long long n,ans=0LL;
vector<string> r;
string s;
map<string,int> mp;
bool cmp(string &a,string &b){
return a.length()<b.length();
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>s;
r.push_back(s);
}
sort(r.begin(),r.end(),cmp);
for(int i=0;i<n;i++){
s=r[i];
ans+=mp[s];
map<string,int> mp2;
for(int j=0;j<s.length();j++){
string tmp="";
for(int k=j;k<s.length();k++){
tmp+=s[k];
if(mp2[tmp]==0) ans+=mp[tmp];
mp2[tmp]++;
}
}
mp[s]++;
}
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |