# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
138617 |
2019-07-30T07:27:25 Z |
KCSC |
Lozinke (COCI17_lozinke) |
C++14 |
|
1000 ms |
55980 KB |
#include <bits/stdc++.h>
using namespace std;
const int DIM = 20005;
string str[DIM];
map<string, set<int>> mmp;
void solve(int n, int &ans) {
mmp.clear();
for (int i = 1; i <= n; ++i) {
ans += mmp[str[i]].size();
for (int p1 = 0; p1 < str[i].length(); ++p1)
for (int p2 = p1; p2 < str[i].length(); ++p2)
mmp[str[i].substr(p1, p2 - p1 + 1)].insert(i);
}
}
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:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int p1 = 0; p1 < str[i].length(); ++p1)
~~~^~~~~~~~~~~~~~~~~
lozinke.cpp:14:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int p2 = p1; p2 < str[i].length(); ++p2)
~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1016 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
4 ms |
1144 KB |
Output is correct |
4 |
Correct |
6 ms |
1144 KB |
Output is correct |
5 |
Correct |
27 ms |
2568 KB |
Output is correct |
6 |
Correct |
41 ms |
3192 KB |
Output is correct |
7 |
Correct |
56 ms |
4600 KB |
Output is correct |
8 |
Correct |
100 ms |
7032 KB |
Output is correct |
9 |
Correct |
312 ms |
12664 KB |
Output is correct |
10 |
Correct |
682 ms |
26856 KB |
Output is correct |
11 |
Correct |
563 ms |
20108 KB |
Output is correct |
12 |
Execution timed out |
1070 ms |
54236 KB |
Time limit exceeded |
13 |
Execution timed out |
1038 ms |
31404 KB |
Time limit exceeded |
14 |
Execution timed out |
1027 ms |
43220 KB |
Time limit exceeded |
15 |
Execution timed out |
1079 ms |
55980 KB |
Time limit exceeded |
16 |
Execution timed out |
1072 ms |
33388 KB |
Time limit exceeded |
17 |
Correct |
368 ms |
10616 KB |
Output is correct |
18 |
Correct |
211 ms |
8696 KB |
Output is correct |
19 |
Execution timed out |
1076 ms |
36700 KB |
Time limit exceeded |
20 |
Correct |
583 ms |
18552 KB |
Output is correct |