#include <bits/stdc++.h>
using namespace std;
struct binary_indexed_tree{
int N;
vector<int> BIT;
binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
}
void add(int i){
i++;
while (i <= N){
BIT[i]++;
i += i & -i;
}
}
int sum(int i){
int ans = 0;
while (i > 0){
ans += BIT[i];
i -= i & -i;
}
return ans;
}
int sum(int L, int R){
return sum(R) - sum(L);
}
};
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 |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
7080 KB |
Output is correct |
2 |
Correct |
908 ms |
7544 KB |
Output is correct |
3 |
Correct |
330 ms |
7252 KB |
Output is correct |
4 |
Correct |
412 ms |
7196 KB |
Output is correct |
5 |
Correct |
728 ms |
4772 KB |
Output is correct |
6 |
Correct |
751 ms |
4808 KB |
Output is correct |
7 |
Correct |
745 ms |
7836 KB |
Output is correct |
8 |
Execution timed out |
1511 ms |
8764 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1561 ms |
2244 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 |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
279 ms |
7080 KB |
Output is correct |
9 |
Correct |
908 ms |
7544 KB |
Output is correct |
10 |
Correct |
330 ms |
7252 KB |
Output is correct |
11 |
Correct |
412 ms |
7196 KB |
Output is correct |
12 |
Correct |
728 ms |
4772 KB |
Output is correct |
13 |
Correct |
751 ms |
4808 KB |
Output is correct |
14 |
Correct |
745 ms |
7836 KB |
Output is correct |
15 |
Execution timed out |
1511 ms |
8764 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |