이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(ll i=(ll)a; i<=(ll)b; i++)
#define ROF(i,b,a) for(ll i=(ll)b; i>=(ll)a; i--)
using namespace std;
const ll maxn = 1e5 + 1;
ll n, m;
string a[maxn], x, y;
void sub1(){
ll co = 0, id;
bool kt1, kt2;
FOR(i,1,m){
cin >> x >> y;
// if (i == 1) continue;
// cout << x << " " << y << endl;
co = 0;
FOR(j,1,n){
kt1 = true; kt2 = true;
id = 0;
FOR(k,0,x.size()-1){
if (a[j][id] != x[k]){
// cout << "hi" << " " << a[j][k] << " " << x[k] << endl;
// cout << 1 << " " << j << " " << k << " " << a[id][k] << " " << x[k] << endl;
kt1 = false;
break;
}
id++;
}
id = a[j].size()-1;
ROF(k,y.size()-1,0){
if (a[j][id] !=y[k]){
// cout << 2 << " " << j << " " << k << " " << a[j][id] << " " << y[k] << endl;
kt2 = false;
break;
}
id--;
}
// cout << i << " " << j << " " << kt1 << " " << kt2 << endl;
if (kt1 == true && kt2 == true){
co++;
}
}
cout << co << "\n";
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
FOR(i,1,n){
cin >> a[i];
}
// x = "aaaa";
// cout << "hi" << " " << x[x.size()] << endl;
sub1();
}
# | 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... |