#include <bits/stdc++.h>
using namespace std;
const int DIM = 20005;
string str[DIM];
map<string, int> mmp;
void solve(int n, int &ans) {
mmp.clear();
for (int i = 1; i <= n; ++i) {
ans += mmp[str[i]];
set<string> mst;
for (int p1 = 0; p1 < str[i].length(); ++p1)
for (int p2 = p1; p2 < str[i].length(); ++p2)
mst.insert(str[i].substr(p1, p2 - p1 + 1));
for (string s : mst)
mmp[s]++;
}
}
int main(void) {
#ifdef HOME
freopen("lozinke.in", "r", stdin);
freopen("lozinke.out", "w", stdout);
#endif
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> str[i];
int ans = 0;
solve(n, ans);
reverse(str + 1, str + n + 1);
solve(n, ans);
cout << ans;
return 0;
}
Compilation message
lozinke.cpp: In function 'void solve(int, int&)':
lozinke.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int p1 = 0; p1 < str[i].length(); ++p1)
~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int p2 = p1; p2 < str[i].length(); ++p2)
~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
3 ms |
888 KB |
Output is correct |
3 |
Correct |
4 ms |
1016 KB |
Output is correct |
4 |
Correct |
5 ms |
1144 KB |
Output is correct |
5 |
Correct |
23 ms |
1244 KB |
Output is correct |
6 |
Correct |
36 ms |
1272 KB |
Output is correct |
7 |
Correct |
48 ms |
2040 KB |
Output is correct |
8 |
Correct |
78 ms |
2936 KB |
Output is correct |
9 |
Correct |
203 ms |
2784 KB |
Output is correct |
10 |
Correct |
451 ms |
7784 KB |
Output is correct |
11 |
Correct |
340 ms |
4472 KB |
Output is correct |
12 |
Execution timed out |
1056 ms |
16696 KB |
Time limit exceeded |
13 |
Correct |
599 ms |
2808 KB |
Output is correct |
14 |
Correct |
687 ms |
14972 KB |
Output is correct |
15 |
Execution timed out |
1073 ms |
16476 KB |
Time limit exceeded |
16 |
Correct |
577 ms |
1144 KB |
Output is correct |
17 |
Correct |
142 ms |
888 KB |
Output is correct |
18 |
Correct |
106 ms |
1016 KB |
Output is correct |
19 |
Correct |
672 ms |
8696 KB |
Output is correct |
20 |
Correct |
288 ms |
1176 KB |
Output is correct |