# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97752 | dalgerok | Lozinke (COCI17_lozinke) | C++17 | 1066 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;
map < string, int > q;
inline void add(string &s){
map < string, int > used;
for(int i = 0; i < (int)s.size(); i++){
string t;
for(int j = i; j < (int)s.size(); j++){
t += s[j];
if(used.find(t) == used.end()){
q[t] += 1;
used[t] = true;
}
}
}
}
inline void del(string &s){
map < string, int > used;
for(int i = 0; i < (int)s.size(); i++){
string t;
for(int j = i; j < (int)s.size(); j++){
t += s[j];
if(used.find(t) == used.end()){
q[t] -= 1;
used[t] = false;
}
}
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
string s[n];
for(int i = 0; i < n; i++){
cin >> s[i];
add(s[i]);
}
int ans = 0;
for(int i = 0; i < n; i++){
del(s[i]);
ans += q[s[i]];
add(s[i]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |