# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116926 | FutymyClone | Lozinke (COCI17_lozinke) | C++14 | 648 ms | 65536 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;
const int N = 2e4 + 5;
int n, ans = 0;
map <string, bitset <N> > mm;
string a[N];
bitset <N> temp;
map <string, int> mm2;
bool cmp (string s, string t) {
if (s.length() != t.length()) return s.length() < t.length();
return s < t;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], mm2[a[i]]++;
sort(a + 1, a + n + 1, cmp);
//for (int i = 1; i <= n; i++) cout << a[i] << "\n";
for (int i = 1; i <= n; i++) {
temp.reset();
for (int l = 0; l < a[i].length(); l++) {
for (int r = 0; r < a[i].length(); r++) {
string t = a[i].substr(l, r - l + 1);
temp |= mm[t];
}
}
ans += temp.count();
mm[a[i]].set(i);
}
for (auto i: mm2) ans += i.second * (i.second - 1) / 2;
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |