#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
map<string, int> dp;
string s[20005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
LL ans = 0;
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> s[i];
int l = s[i].length();
vector<string> v;
for(int j=0;j<l;j++){
for(int k=j;k<l;k++){
int le = k-j+1;
string x = s[i].substr(j, le);
v.emplace_back(x);
}
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for(int i=0;i<v.size();i++){
dp[v[i]]++;
}
}
for(int i=1;i<=n;i++){
ans += dp[s[i]];
}
cout << ans-n << "\n";
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v.size();i++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1016 KB |
Output is correct |
2 |
Correct |
3 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1216 KB |
Output is correct |
4 |
Correct |
4 ms |
1216 KB |
Output is correct |
5 |
Correct |
13 ms |
1604 KB |
Output is correct |
6 |
Correct |
23 ms |
1604 KB |
Output is correct |
7 |
Correct |
32 ms |
2280 KB |
Output is correct |
8 |
Correct |
45 ms |
3192 KB |
Output is correct |
9 |
Correct |
109 ms |
3192 KB |
Output is correct |
10 |
Correct |
235 ms |
8412 KB |
Output is correct |
11 |
Correct |
201 ms |
8412 KB |
Output is correct |
12 |
Correct |
574 ms |
17548 KB |
Output is correct |
13 |
Correct |
347 ms |
17548 KB |
Output is correct |
14 |
Correct |
382 ms |
17548 KB |
Output is correct |
15 |
Correct |
560 ms |
17776 KB |
Output is correct |
16 |
Correct |
379 ms |
17776 KB |
Output is correct |
17 |
Correct |
159 ms |
17776 KB |
Output is correct |
18 |
Correct |
134 ms |
17776 KB |
Output is correct |
19 |
Correct |
402 ms |
17776 KB |
Output is correct |
20 |
Correct |
175 ms |
17776 KB |
Output is correct |