이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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());
reverse(p.begin(), p.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;
}
}
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |