# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
126391 | TadijaSebez | Lamps (JOI19_lamps) | C++11 | 1074 ms | 2696 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=1000050;
const int inf=1e9+7;
char a[N],b[N];
int dp[N][2];
int main()
{
int n;
scanf("%i",&n);
scanf("%s",a+1);
scanf("%s",b+1);
dp[0][0]=0;
dp[0][1]=inf;
int best[2][2];
best[0][0]=1;
best[0][1]=inf;
best[1][0]=inf;
best[1][1]=inf;
for(int i=1;i<=n;i++)
{
if(a[i]!=b[i])
{
dp[i][1]=min(dp[i-1][1],dp[i-1][0]+1);
dp[i][0]=inf;
}
else
{
dp[i][1]=inf;
dp[i][0]=min(dp[i-1][1],dp[i-1][0]);
}
/*if(b[i]!=b[i-1])
{
swap(best[0][0],best[1][0]);
best[0][0]++;
swap(best[0][1],best[1][1]);
best[0][1]++;
}
dp[i][1]=min(dp[i][1],min(best[0][1],best[1][1]));
dp[i][0]=min(dp[i][0],min(best[0][0],best[1][0]));
best[0][1]=min(best[0][1],dp[i][1]+1);
best[0][0]=min(best[0][0],dp[i][0]+1);*/
char pre=0;
int cnt=0;
for(int j=i;j>=1;j--)
{
if(pre!=b[j]) cnt++;
pre=b[j];
dp[i][1]=min(dp[i][1],dp[j-1][1]+cnt/2+1);
dp[i][0]=min(dp[i][0],dp[j-1][0]+cnt/2+1);
}
}
printf("%i\n",min(dp[n][0],dp[n][1]));
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |