#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M;
cin >> N >> M;
vector<string> S(N);
for (int i = 0; i < N; i++){
cin >> S[i];
}
for (int i = 0; i < M; i++){
string P, Q;
cin >> P >> Q;
int ans = 0;
for (int j = 0; j < N; j++){
if (S[j].size() >= P.size() && S[j].size() >= Q.size()){
if (S[j].substr(0, P.size()) == P && S[j].substr(S[j].size() - Q.size()) == Q){
ans++;
}
}
}
cout << ans << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
3148 KB |
Output is correct |
2 |
Correct |
848 ms |
3468 KB |
Output is correct |
3 |
Correct |
314 ms |
3324 KB |
Output is correct |
4 |
Correct |
413 ms |
3420 KB |
Output is correct |
5 |
Correct |
671 ms |
2484 KB |
Output is correct |
6 |
Correct |
695 ms |
2328 KB |
Output is correct |
7 |
Correct |
767 ms |
2484 KB |
Output is correct |
8 |
Correct |
1415 ms |
3020 KB |
Output is correct |
9 |
Correct |
1335 ms |
2896 KB |
Output is correct |
10 |
Execution timed out |
1558 ms |
2892 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1575 ms |
1876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
248 ms |
3148 KB |
Output is correct |
9 |
Correct |
848 ms |
3468 KB |
Output is correct |
10 |
Correct |
314 ms |
3324 KB |
Output is correct |
11 |
Correct |
413 ms |
3420 KB |
Output is correct |
12 |
Correct |
671 ms |
2484 KB |
Output is correct |
13 |
Correct |
695 ms |
2328 KB |
Output is correct |
14 |
Correct |
767 ms |
2484 KB |
Output is correct |
15 |
Correct |
1415 ms |
3020 KB |
Output is correct |
16 |
Correct |
1335 ms |
2896 KB |
Output is correct |
17 |
Execution timed out |
1558 ms |
2892 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |