Skip to content
Snippets Groups Projects
Commit c96e1374 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Add URI1364

parent 2f9b60fa
No related branches found
No related tags found
No related merge requests found
#include <bits/stdc++.h>
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define sz size()
#define pb push_back
#define ende '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
while (cin >> n >> m && (n || m)) {
vector<string> emo(n);
for (auto &i : emo) cin >> i;
cin.ignore();
int ans = 0;
for (int i = 0; i < m; ++i) {
string s;
getline(cin, s);
for (int j = 0; j < s.sz; ++j) {
for (int k = 0; k < n; ++k) {
if (s[j] == emo[k].back()) {
for (int l = j, ll = emo[k].sz - 1; ll >= 0 && l >= 0; ll--, l--) {
if (s[l] != emo[k][ll])
break;
if (ll == 0) {
s[j] = ' ';
ans++;
}
}
}
}
}
}
cout << ans << ende;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment