# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79938 | luckyboy | Lozinke (COCI17_lozinke) | C++14 | 651 ms | 66560 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 FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 20005
#define maxm 500005
#define pii pair <int,int>
#define Task "Lozinke"
using namespace std;
int n;
string s[maxn];
map <string,int> dd,dd1;
map <string,bool> ok[maxn],ok1[maxn];
long long ans;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen(Task".inp", "r",stdin);
//freopen(Task".out", "w",stdout);
cin >> n;
FOR(i,1,n)
{
cin >> s[i];
int temp = s[i].size();
FOR(j,1,temp)
FOR(pos,0,temp - j)
{
string ww = s[i].substr(pos,j);
if (ok[i][ww]) continue;
ok[i][ww] = 1;
ans += dd[ww];
}
++dd[s[i]];
}
FORD(i,n,1)
{
int temp = s[i].size();
FOR(j,1,temp)
FOR(pos,0,temp - j)
{
string ww = s[i].substr(pos,j);
if (ok1[i][ww]) continue;
ok1[i][ww] = 1;
ans += dd1[ww];
}
++dd1[s[i]];
// FOR(j,1,temp)
// FOR(pos,0,temp - j)
// {
// string ww = s[i].substr(pos,j);
// ok1[i][ww] = 0;
// }
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |