# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1067187 | Celebi_276 | Lozinke (COCI17_lozinke) | C++17 | 303 ms | 16748 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 <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define MultiTest(k) int k; cin >> k; while (k--)
#define all(v) v.begin(), v.end()
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>
#define NAME ""
string s[20022];
int n, Z(0);
map <string, int> mp, ok;
void process (string s) {
int l = s.length();
vector <string> C;
for (int i = 0; i < l; i++)
for (int j = i; j < l; j++) {
string t = s.substr(i, j - i + 1);
if (!ok[t]) C.push_back(t);
ok[t] = 1;
}
for (string t : C) mp[t]++;
ok.clear();
}
signed main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
if (fopen(NAME".INP", "r"))
{
freopen(NAME".INP", "r", stdin);
freopen(NAME".OUT", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s[i];
process(s[i]);
}
for (int i = 1; i <= n; i++) Z += mp[s[i]];
cout << Z - n;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |