# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79819 | pzdba | Lozinke (COCI17_lozinke) | C++14 | 574 ms | 17776 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;
typedef long long LL;
map<string, int> dp;
string s[20005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
LL ans = 0;
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> s[i];
int l = s[i].length();
vector<string> v;
for(int j=0;j<l;j++){
for(int k=j;k<l;k++){
int le = k-j+1;
string x = s[i].substr(j, le);
v.emplace_back(x);
}
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for(int i=0;i<v.size();i++){
dp[v[i]]++;
}
}
for(int i=1;i<=n;i++){
ans += dp[s[i]];
}
cout << ans-n << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |