| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1002352 | nmts | Selling RNA Strands (JOI16_selling_rna) | C++17 | 1266 ms | 1048576 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;
unordered_map<string, int> prefix_count, suffix_count;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vector<string> RNA(N);
    for (int i = 0; i < N; ++i) {
        cin >> RNA[i];
    }
    vector<pair<string, string>> orders(M);
    for (int j = 0; j < M; ++j) {
        cin >> orders[j].first >> orders[j].second;
    }
    // Count the prefix and suffix occurrences
    for (const string& s : RNA) {
        for (int len = 1; len <= s.size(); ++len) {
            prefix_count[s.substr(0, len)]++;
            suffix_count[s.substr(s.size() - len, len)]++;
        }
    }
    // Process each order
    for (const auto& order : orders) {
        const string& P = order.first;
        const string& Q = order.second;
        int prefixCount = prefix_count[P];
        int suffixCount = suffix_count[Q];
        cout << min(prefixCount, suffixCount) << '\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... | ||||
