This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n,m;
cin>>n>>m;
string s[n+5],p[m+5],q[m+5];
for(int i=1;i<=n;i++){
cin>>s[i];
}
for(int i=1;i<=m;i++){
cin>>p[i]>>q[i];
int ans=0;
for(int j=1;j<=n;j++){
if(s[j].size()>=max(p[i].size(),q[i].size())){
if(s[j].substr(0,p[i].size())==p[i]&&s[j].substr(s[j].size()-q[i].size(),q[i].size())==q[i]){
ans++;
}
}
}
cout<<ans<<"\n";
}
}
# | 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... |