0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00

P4421 [COCI2017-2018#1] Lozinke

https://www.luogu.com.cn/record/93125374
This commit is contained in:
Baoshuo Ren 2022-11-07 07:43:04 +08:00
parent a041302b0d
commit 8d5d8efebd
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

45
Luogu/P4421/P4421.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <iostream>
#include <string>
#include <unordered_map>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 20005;
int n, ans;
std::string s[N];
std::unordered_map<std::string, int> map;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
std::unordered_map<std::string, bool> map2;
cin >> s[i];
for (int j = 0; j < s[i].size(); j++) {
for (int k = j; k < s[i].size(); k++) {
std::string t = s[i].substr(j, k - j + 1);
if (!map2[t]) {
map[t]++;
map2[t] = true;
}
}
}
}
for (int i = 1; i <= n; i++) {
ans += map[s[i]] - 1;
}
cout << ans << endl;
return 0;
}