이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Testing if the simplified problem statement is accurate.
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define debug if (true) cerr
using ll = long long;
const int MAXN = 15;
int N, M;
int C[MAXN];
int ans[MAXN];
void brute(int i, int v, int c1, int c2) {
int newV = v;
if (i == 0) {
// First segment
rep(j, i, N) {
if (C[j] != c1) newV++;
brute(j+1, newV, c2, c1);
}
} else {
// Try making last segment
rep(j, i, N) if (C[j] != c1) newV++;
ans[c1] = min(newV, ans[c1]);
ans[c2] = min(newV, ans[c2]);
// Make middle segment
newV = v;
rep(j, i, N) {
if (C[j] != c1) newV++;
if ((j-i) % 2 == 1) brute(j+1, newV, c2, c1);
}
}
}
void solve() {
cin >> N >> M;
rep(i, 0, N) {
cin >> C[i];
C[i]--;
}
rep(i, 0, M) ans[i] = N;
rep(c1, 0, M) {
rep(c2, 0, M) {
brute(0, 0, c1, c2);
}
}
rep(i, 0, M) cout << ans[i] << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
# | 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... |