# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734118 | JellyTheOctopus | Lozinke (COCI17_lozinke) | C++17 | 348 ms | 16716 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;
int N;
vector<string> arr;
map<string, int> freq;
int valid(string s) {
int len = (int)s.size();
int ans = 0;
set<string> unique;
for (int i = 0; i < len; i++) {
for (int j = i; j < len; j++) {
string r = s.substr(i, j-i+1);
unique.insert(r);
}
}
for (auto it = unique.begin(); it != unique.end(); it++) {
if ((int)(*it).size() == len) {
ans += freq[*it]-1;
continue;
}
ans += freq[*it];
}
return ans;
}
int main() {
cin >> N;
arr.resize(N+1);
for (int i = 1; i <= N; i++) {
cin >> arr[i];
freq[arr[i]]++;
}
int ans = 0;
for (int i = 1; i <= N; i++) {
ans += valid(arr[i]);
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |