# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1252943 | Semen07 | Rope (JOI17_rope) | C++20 | 47 ms | 48448 KiB |
#include <bits/stdc++.h>
int main() {
freopen("main.in", "r", stdin);
freopen("main.out", "w", stdout);
size_t n, m;
std::cin >> n >> m;
std::vector<size_t> a(n);
for (size_t i = 0; i < n; ++i) {
std::cin >> a[i];
--a[i];
}
for (size_t f = 0; f < m; ++f) {
size_t ans = n;
for (size_t s = 0; s < m; ++s) {
size_t score0 = 0;
for (size_t i = 0; i < n; i += 2) {
if (i + 1 < n) {
if (a[i] == a[i + 1] && (a[i] == f || a[i] == s)) continue;
if (a[i] == f || a[i + 1] == f || a[i] == s || a[i + 1] == s) score0++;
else score0 += 2;
} else {
if (a[i] != f && a[i] != s) score0++;
}
}
size_t score1 = 0;
for (size_t i = 0; i < n + 1; i += 2) {
if (i > 0 && i < n) {
if (a[i] == a[i - 1] && (a[i] == f || a[i] == s)) continue;
if (a[i] == f || a[i - 1] == f || a[i] == s || a[i - 1] == s) score1++;
else score1 += 2;
} else {
if (i == n) --i;
if (a[i] != f && a[i] != s) score1++;
}
}
ans = std::min({ans, score0, score1});
}
std::cout << ans << '\n';
}
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |