이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[1000003],b[1000003],dp[1000002][3];
int main(){
cin >> n;
for(int i=1; i<=n; i++){
char x;
cin >> x;
a[i] = (x == '1');
}
for(int i=1; i<=n; i++){
char x;
cin >> x;
b[i] = (x == '1');
}
dp[0][0] = dp[0][1] = 9999999999999;
dp[0][2] = 0;
for(int i=1; i<=n; i++){
for(int j=0; j<3; j++){
dp[i][j] = 10000000000000;
for(int k=0; k<3; k++){
ll cur = 0;
if(j != 2 && j != k)cur++;
ll ok = 0;
if(k == 2 && a[i - 1] != b[i - 1])ok = 1;
if(k != 2 && k != b[i - 1])ok = 1;
ll es = a[i];
if(j != 2)es = j;
if(es != b[i])cur += (ok ^ 1);
dp[i][j] = min(dp[i][j] , dp[i - 1][k] + cur);
}
}
}
cout << min(dp[n][0] , min(dp[n][1] , dp[n][2]));
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... |