# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
837297 | unnick | Rope (JOI17_rope) | C++14 | 2540 ms | 980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> colors(n);
vector<int> color_counts(m, 0);
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
colors[i] = tmp-1;
color_counts[tmp-1]++;
}
if (m == 1) {
cout << "0\n";
return 0;
}
vector<int> answers(m, 2000000000);
for (int q = 0; q < 2; q++) {
// cout << "q=" << q << "\n";
// vector<int> col_ngb;
// for (int i = q; i < n-1; q+=2) {
// int a = colors[i];
// int b = colors[i+1];
// if (a==b) continue;
// col_ngb[a]++;
// col_ngb[b]++;
// }
for (int c = 0; c < m; c++) {
// cout << " c=" << c << "\n";
int dom = -1;
int domc = 0;
for (int d = 0; d < m; d++) {
if (d==c) continue;
// cout << " d=" << d << "\n";
int count = n&1?q?(colors[0]==d):(colors[n-1]==d):q?((colors[0]==d)+(colors[n-1]==d)):0;
for (int i = q; i < n-1; i+=2) {
int a = colors[i];
int b = colors[i+1];
if (a==c || b==c) continue;
if (a == d) count++;
if (b == d) count++;
}
// cout << " " << count << "\n";
if(count > domc) {
domc = count;
dom = d;
}
}
answers[c] = min(answers[c], n-color_counts[c]-domc);
// cout << n - color_counts[c] - domc << "\n";
}
}
for (int a : answers) {
cout << a << "\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... |