# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20925 | gs14004 | Rope (JOI17_rope) | C++11 | 29 ms | 21552 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long lint;
typedef long double llf;
using namespace std;
typedef pair<int, int> pi;
int n, m, a[1000005];
int ans[1000005];
int dp[1000005][3];
int solve(int x, int y){
for(int i=1; i<=n; i++){
dp[i][0] = dp[i-1][1] + (a[i] != x);
dp[i][1] = min(dp[i-1][0] + (a[i] != x), dp[i-1][2] + (a[i] != y));
dp[i][2] = dp[i-1][1] + (a[i] != y);
}
return min({dp[n][0], dp[n][1], dp[n][2]});
}
int main(){
scanf("%d %d",&n,&m);
for(int i=1; i<=n; i++){
scanf("%d",&a[i]);
}
if(m > 10) return 0;
memset(ans, 0x3f, sizeof(ans));
for(int i=1; i<=m; i++){
for(int j=1; j<=i; j++){
int x = solve(i, j);
ans[i] = min(ans[i], x);
ans[j] = min(ans[j], x);
}
}
for(int i=1; i<=m; i++) printf("%d\n", ans[i]);
}
컴파일 시 표준 에러 (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... |