#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
string s[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
/*f (fopen("test.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.ans", "w", stdout);
}*/
ll n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> s[i];
}
while (m--){
string t, p;
cin >> t >> p;
reverse(p.begin(), p.end());
ll res = 0;
for (int i = 1; i <= n; i++){
if (t.length() > s[i].length() || p.length() > s[i].length()){
continue;
}
bool flag = true;
for (int j = 0; j < (int)t.length(); j++){
if (t[j] != s[i][j]) flag = false;
}
reverse(s[i].begin(), s[i].end());
for (int j = 0; j < (int)p.length(); j++){
if (p[j] != s[i][j]) flag = false;
}
reverse(s[i].begin(), s[i].end());
if (flag) res++;
}
cout << res << endl;
}
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3456 KB |
Output is correct |
2 |
Correct |
3 ms |
3456 KB |
Output is correct |
3 |
Correct |
3 ms |
3456 KB |
Output is correct |
4 |
Correct |
3 ms |
3456 KB |
Output is correct |
5 |
Correct |
3 ms |
3456 KB |
Output is correct |
6 |
Correct |
3 ms |
3584 KB |
Output is correct |
7 |
Correct |
3 ms |
3456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1566 ms |
5624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1563 ms |
3576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3456 KB |
Output is correct |
2 |
Correct |
3 ms |
3456 KB |
Output is correct |
3 |
Correct |
3 ms |
3456 KB |
Output is correct |
4 |
Correct |
3 ms |
3456 KB |
Output is correct |
5 |
Correct |
3 ms |
3456 KB |
Output is correct |
6 |
Correct |
3 ms |
3584 KB |
Output is correct |
7 |
Correct |
3 ms |
3456 KB |
Output is correct |
8 |
Execution timed out |
1566 ms |
5624 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |