| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 425285 | songc | Vim (BOI13_vim) | C++14 | 37 ms | 34108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define Mup(a,x) a=max(a, x)
#define mup(a,x) a=min(a, x)
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define INF (1ll<<60)
#define MOD 1'000'000'007
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int M, N, X, sum, ans=MOD;
int A[70707], D[70707][11][11];
bool E[70707];
int main(){
char c;
bool tf = false;
scanf("%d", &M);
for (int i=0; i<M; i++){
scanf(" %c", &c);
if (c != 'e'){
A[++N] = c-'a'+1+(c<'e'?1:0);
if (tf) X = N;
E[N] = tf, tf = false;
}
else tf = true, sum += 2;
}
if (!X){puts("0"); return 0;}
memset(D, 1, sizeof D);
for (int i=2; i<=10; i++) D[1][i][0] = 2;
for (int i=1; i<N; i++){
for (int j=2; j<=10; j++){
if (A[i+1] == j){
if (i+1>=X) ans = min(ans, min(D[i][j][0], D[i][j][1]));
for (int k=2; k<=10; k++) D[i+1][k][0] = min(D[i+1][k][0], D[i][j][0]+2);
}
else{
if (!E[i+1]) D[i+1][j][0] = min(D[i+1][j][0], D[i][j][0]);
D[i+1][j][1] = min(D[i+1][j][1], min(D[i][j][0], D[i][j][1])+1);
for (int k=2; k<=10; k++) D[i+1][j][k] = min(D[i+1][j][k], D[i][j][0]+3);
}
for (int k=2; k<=10; k++){
if (A[i+1] == j){
if (j == k) for (int l=2; l<=10; l++) D[i+1][l][0] = min(D[i+1][l][0], D[i][j][k]+2);
else D[i+1][k][0] = min(D[i+1][k][0], D[i][j][k]);
}
else if (A[i+1] != k) D[i+1][j][k] = min(D[i+1][j][k], D[i][j][k]+1);
}
}
}
printf("%d\n", ans+sum);
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... | ||||
