#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 < n; 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 |
3412 KB |
Output is correct |
3 |
Correct |
2 ms |
3412 KB |
Output is correct |
4 |
Correct |
2 ms |
3412 KB |
Output is correct |
5 |
Correct |
2 ms |
3412 KB |
Output is correct |
6 |
Correct |
2 ms |
3412 KB |
Output is correct |
7 |
Correct |
2 ms |
3412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
6308 KB |
Output is correct |
2 |
Correct |
604 ms |
6316 KB |
Output is correct |
3 |
Correct |
230 ms |
6252 KB |
Output is correct |
4 |
Correct |
279 ms |
6228 KB |
Output is correct |
5 |
Correct |
532 ms |
5320 KB |
Output is correct |
6 |
Correct |
532 ms |
5232 KB |
Output is correct |
7 |
Correct |
478 ms |
5568 KB |
Output is correct |
8 |
Correct |
1027 ms |
5856 KB |
Output is correct |
9 |
Correct |
901 ms |
5852 KB |
Output is correct |
10 |
Correct |
1459 ms |
5848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1568 ms |
3416 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 |
3412 KB |
Output is correct |
3 |
Correct |
2 ms |
3412 KB |
Output is correct |
4 |
Correct |
2 ms |
3412 KB |
Output is correct |
5 |
Correct |
2 ms |
3412 KB |
Output is correct |
6 |
Correct |
2 ms |
3412 KB |
Output is correct |
7 |
Correct |
2 ms |
3412 KB |
Output is correct |
8 |
Correct |
180 ms |
6308 KB |
Output is correct |
9 |
Correct |
604 ms |
6316 KB |
Output is correct |
10 |
Correct |
230 ms |
6252 KB |
Output is correct |
11 |
Correct |
279 ms |
6228 KB |
Output is correct |
12 |
Correct |
532 ms |
5320 KB |
Output is correct |
13 |
Correct |
532 ms |
5232 KB |
Output is correct |
14 |
Correct |
478 ms |
5568 KB |
Output is correct |
15 |
Correct |
1027 ms |
5856 KB |
Output is correct |
16 |
Correct |
901 ms |
5852 KB |
Output is correct |
17 |
Correct |
1459 ms |
5848 KB |
Output is correct |
18 |
Execution timed out |
1568 ms |
3416 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |