#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 5;
string a[N];
bool check(string &x, string &y){
// int l = 0, r = 0;
// int n = x.size(), m = y.size();
// while (l < n && r < m){
// if (x[l] == y[r]){
// l++;
// r++;
// }
// else r++;
// }
// return l == n;
return y.find(x) != string::npos;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int ans = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (i != j) ans += check(a[j], a[i]);
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
900 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
3 ms |
856 KB |
Output is correct |
5 |
Correct |
16 ms |
860 KB |
Output is correct |
6 |
Correct |
35 ms |
860 KB |
Output is correct |
7 |
Correct |
53 ms |
860 KB |
Output is correct |
8 |
Correct |
39 ms |
860 KB |
Output is correct |
9 |
Execution timed out |
1031 ms |
860 KB |
Time limit exceeded |
10 |
Execution timed out |
1027 ms |
856 KB |
Time limit exceeded |
11 |
Execution timed out |
1056 ms |
860 KB |
Time limit exceeded |
12 |
Execution timed out |
1054 ms |
860 KB |
Time limit exceeded |
13 |
Execution timed out |
1054 ms |
860 KB |
Time limit exceeded |
14 |
Execution timed out |
1034 ms |
860 KB |
Time limit exceeded |
15 |
Execution timed out |
1070 ms |
860 KB |
Time limit exceeded |
16 |
Execution timed out |
1049 ms |
860 KB |
Time limit exceeded |
17 |
Execution timed out |
1025 ms |
860 KB |
Time limit exceeded |
18 |
Execution timed out |
1046 ms |
860 KB |
Time limit exceeded |
19 |
Execution timed out |
1050 ms |
860 KB |
Time limit exceeded |
20 |
Execution timed out |
1073 ms |
860 KB |
Time limit exceeded |