# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917960 | 406 | Lozinke (COCI17_lozinke) | C++17 | 254 ms | 35904 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>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int64_t INF = 1ll << 60;
const int N = 2e4 + 5;
string s[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<string> V;
FOR(i, 0, n) {
cin >> s[i];
vector<string> v;
FOR(k, 0, s[i].size()) {
string a;
FOR(j, k, s[i].size()) {
a += s[i][j];
v.push_back(a);
}
}
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
V.insert(V.end(), v.begin(), v.end());
}
sort(V.begin(), V.end());
int ans = -n;
FOR(i, 0, n) {
int L = lower_bound(V.begin(), V.end(), s[i]) - V.begin();
int R = upper_bound(V.begin(), V.end(), s[i]) - V.begin();
ans += R - L;
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |