# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1002352 | nmts | Selling RNA Strands (JOI16_selling_rna) | C++17 | 1266 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |