| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 332608 | casperwang | Selling RNA Strands (JOI16_selling_rna) | C++14 | 1589 ms | 6088 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>
using namespace std;
const int MAXN = 100000;
const int BLOCK = 1000;
int n, m;
string s[MAXN];
string p, q;
int now, ans;
bool pre(string a, string b) {
if (a.size() < b.size()) return 0;
for (int i = 0; i < b.size(); i++)
if (a[i] != b[i]) return 0;
return 1;
}
bool suf(string a, string b) {
if (a.size() < b.size()) return 0;
for (int i = 0; i < b.size(); i++)
if (a[a.size()-1-i] != b[b.size()-1-i]) return 0;
return 1;
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> s[i];
}
sort(s, s+n);
for (int i = 0; i < m; i++) {
cin >> p >> q;
now = lower_bound(s, s+n, p) - s;
ans = 0;
while (now < n && pre(s[now], p)) {
if (suf(s[now], q)) ans++;
now++;
}
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... | ||||
