#include <bits/stdc++.h>
using namespace std;
#define sz(a) (int)a.size()
const int mxN = (int)1e5+10;
int n,m;
string s[mxN];
int main()
{
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> s[i];
for(int i = 0; i < m; i++){
string a,b; cin>>a >> b; int ans = 0;
for(int j = 0; j < m; j++){
if(sz(s[j])<max(sz(a),sz(b))) continue;
if(s[j].substr(0,sz(a))==a and s[j].substr(sz(s[j])-sz(b),sz(b))==b)ans++;
}
cout << ans << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3412 KB |
Output is correct |
2 |
Correct |
2 ms |
3384 KB |
Output is correct |
3 |
Correct |
2 ms |
3412 KB |
Output is correct |
4 |
Correct |
2 ms |
3432 KB |
Output is correct |
5 |
Correct |
2 ms |
3412 KB |
Output is correct |
6 |
Correct |
2 ms |
3432 KB |
Output is correct |
7 |
Correct |
3 ms |
3412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
10220 KB |
Output is correct |
2 |
Correct |
651 ms |
10136 KB |
Output is correct |
3 |
Correct |
237 ms |
10204 KB |
Output is correct |
4 |
Correct |
282 ms |
10216 KB |
Output is correct |
5 |
Correct |
512 ms |
7624 KB |
Output is correct |
6 |
Correct |
541 ms |
7628 KB |
Output is correct |
7 |
Correct |
506 ms |
10952 KB |
Output is correct |
8 |
Correct |
1018 ms |
11724 KB |
Output is correct |
9 |
Correct |
897 ms |
11600 KB |
Output is correct |
10 |
Correct |
1398 ms |
9300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1560 ms |
3800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3412 KB |
Output is correct |
2 |
Correct |
2 ms |
3384 KB |
Output is correct |
3 |
Correct |
2 ms |
3412 KB |
Output is correct |
4 |
Correct |
2 ms |
3432 KB |
Output is correct |
5 |
Correct |
2 ms |
3412 KB |
Output is correct |
6 |
Correct |
2 ms |
3432 KB |
Output is correct |
7 |
Correct |
3 ms |
3412 KB |
Output is correct |
8 |
Correct |
175 ms |
10220 KB |
Output is correct |
9 |
Correct |
651 ms |
10136 KB |
Output is correct |
10 |
Correct |
237 ms |
10204 KB |
Output is correct |
11 |
Correct |
282 ms |
10216 KB |
Output is correct |
12 |
Correct |
512 ms |
7624 KB |
Output is correct |
13 |
Correct |
541 ms |
7628 KB |
Output is correct |
14 |
Correct |
506 ms |
10952 KB |
Output is correct |
15 |
Correct |
1018 ms |
11724 KB |
Output is correct |
16 |
Correct |
897 ms |
11600 KB |
Output is correct |
17 |
Correct |
1398 ms |
9300 KB |
Output is correct |
18 |
Execution timed out |
1560 ms |
3800 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |