# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80283 | Genezio | Lozinke (COCI17_lozinke) | C++14 | 1016 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>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define ll long long
const int N = 100010;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
string s;
map< string,set<int> > m;
map< string,set<int> > subs;
map< string,set<int> > f;
string x;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int ans=0;
for(int i=0;i<n;i++) {
cin>>s;
ans+=subs[s].size();
//ans+=f[s].size();
//cout<<i<<" "<<ans<<"\n";
//f[s].insert(i);
for(int k=0;k<s.size();k++) {
string p=x;
for(int j=k;j<s.size();j++) {
p+=s[j];
ans+=m[p].size();
//if(k==0&&j==s.size()-1) continue;
subs[p].insert(i);
//ans+=f[p].size();
//cout<<i<<" "<<k<<" "<<j<<" "<<ans<<"\n";
}
}
m[s].insert(i);
}
cout<<ans<<"\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |