# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116809 | minhcool | Lozinke (COCI17_lozinke) | C++17 | 193 ms | 2936 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
int n, ans;
map<string, int> mp;
set<string> se2;
set<string> se;
signed main(){
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++){
string x;
cin >> x;
mp[x]++;
se.insert(x);
}
for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++){
int cnt = 0;
string x = it->first;
se2.clear();
for(int i = 0; i < x.length(); i++){
for(int j = 1; j + i <= x.length(); j++){
string tmp = x.substr(i, j);
if(se.find(tmp) != se.end() && se2.find(tmp) == se2.end()){
//cout << i << " " << j << " " << x << " " << tmp << "\n";
cnt += mp[tmp];
se2.insert(tmp);
}
}
}
cnt--;
ans += cnt * it->second;
//cout << x << " " << cnt << endl;
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |