답안 #1002352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002352 2024-06-19T13:10:36 Z nmts Selling RNA Strands (JOI16_selling_rna) C++17
0 / 100
1266 ms 1048576 KB
#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

selling_rna.cpp: In function 'int main()':
selling_rna.cpp:25:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int len = 1; len <= s.size(); ++len) {
      |                           ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1266 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 5720 KB Output is correct
2 Incorrect 14 ms 3932 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -