#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
const int MOD = 1e9 + 7;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, q;
cin >> n >> q;
string s[n];
for(auto &i : s){
cin >> i;
}
auto solve = [](string &s, string &a, string &b) -> bool{
if(a.size() > s.size() || b.size() > s.size()){
return 0;
}
if(s.substr(0, a.size()) != a) return 0;
if(s.substr(s.size() - b.size(), b.size()) != b) return 0;
return 1;
};
while(q--){
string a, b;
cin >> a >> b;
int ans = 0;
for(auto &i : s){
ans += solve(i, a, b);
}
cout << ans << endl;
}
return 0;
}
// by me
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
6488 KB |
Output is correct |
2 |
Correct |
561 ms |
6560 KB |
Output is correct |
3 |
Correct |
173 ms |
6644 KB |
Output is correct |
4 |
Correct |
237 ms |
6676 KB |
Output is correct |
5 |
Correct |
530 ms |
4176 KB |
Output is correct |
6 |
Correct |
495 ms |
4180 KB |
Output is correct |
7 |
Correct |
460 ms |
7616 KB |
Output is correct |
8 |
Correct |
1151 ms |
8400 KB |
Output is correct |
9 |
Correct |
926 ms |
8424 KB |
Output is correct |
10 |
Correct |
1423 ms |
6100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1568 ms |
2364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
132 ms |
6488 KB |
Output is correct |
9 |
Correct |
561 ms |
6560 KB |
Output is correct |
10 |
Correct |
173 ms |
6644 KB |
Output is correct |
11 |
Correct |
237 ms |
6676 KB |
Output is correct |
12 |
Correct |
530 ms |
4176 KB |
Output is correct |
13 |
Correct |
495 ms |
4180 KB |
Output is correct |
14 |
Correct |
460 ms |
7616 KB |
Output is correct |
15 |
Correct |
1151 ms |
8400 KB |
Output is correct |
16 |
Correct |
926 ms |
8424 KB |
Output is correct |
17 |
Correct |
1423 ms |
6100 KB |
Output is correct |
18 |
Execution timed out |
1568 ms |
2364 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |