#include <iostream>
#include <vector>
using namespace std;
int n, m;
vector<string> S;
int solve(string pref, string suf) {
int ans = 0;
for (int i = 0; i < n; i++) {
string cur = S[i];
if (cur.size() < pref.size() or cur.size() < suf.size()) continue;
if (cur.substr(0, pref.size()) == pref and cur.substr(cur.size() - suf.size(), suf.size()) == suf) ans++;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
S.resize(n);
for (int i = 0; i < n; i++) {
cin >> S[i];
}
while (m--) {
string pref, suf;
cin >> pref >> suf;
cout << solve(pref, suf) << '\n';
}
return 0;
}
# |
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 |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
464 ms |
3688 KB |
Output is correct |
2 |
Execution timed out |
1515 ms |
4044 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1586 ms |
2260 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 |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
464 ms |
3688 KB |
Output is correct |
9 |
Execution timed out |
1515 ms |
4044 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |