# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914281 | OAleksa | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1552 ms | 10712 KiB |
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>
//ako ovaj vaso daso misli da me pobedjuje.....
using namespace std;
#define int long long
#define f first
#define s second
const int N = 1e5 + 69;
const int p = 31;
const int mod = 1e9 + 7;
const int B = 750;
int trie[N][26], node, n, q;
string s[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> q;
for (int i = 1;i <= n;i++)
cin >> s[i];
while (q--) {
string p, q;
cin >> p >> q;
int sz1 = p.size();
int sz2 = q.size();
int ans = 0;
for (int i = 1;i <= n;i++) {
int ptr1 = 0, ptr2 = q.size() - 1;
for (int j = 0;j < s[i].size();j++) {
if (ptr1 < sz1 && s[i][j] == p[ptr1])
ptr1++;
else
break;
}
if (ptr1 == sz1) {
for (int j = s[i].size() - 1;j >= 0;j--) {
if (ptr2 >= 0 && s[i][j] == q[ptr2])
ptr2--;
else
break;
}
if (ptr2 == -1)
++ans;
}
}
cout << ans << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | 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... |