| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1093843 | IvanGar | Martian DNA (BOI18_dna) | C++17 | 86 ms | 12424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <unordered_map>
#include <climits>
using namespace std;
int main() {
int n, a, r;
cin >> n >> a >> r;
vector<int> dna(n);
for (int i = 0; i < n; ++i) {
cin >> dna[i];
}
unordered_map<int, int> required;
for (int i = 0; i < r; ++i) {
int nucleobase, quantity;
cin >> nucleobase >> quantity;
required[nucleobase] = quantity;
}
unordered_map<int, int> current_count;
int matched = 0;
int min_len = INT_MAX;
int start = 0;
for (int end = 0; end < n; ++end) {
int end_base = dna[end];
if (required.find(end_base) != required.end()) {
current_count[end_base]++;
if (current_count[end_base] == required[end_base]) {
matched++;
}
}
while (matched == required.size()) {
min_len = min(min_len, end - start + 1);
int start_base = dna[start];
if (required.find(start_base) != required.end()) {
current_count[start_base]--;
if (current_count[start_base] < required[start_base]) {
matched--;
}
}
start++;
}
}
if (min_len == INT_MAX) {
cout << "impossible" << endl;
} else {
cout << min_len << endl;
}
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... | ||||
