This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int dp[1000010][3];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<int> haha(n+2);
vector<int> bruh(n+2);
for(int i = 1; i <= n; i++) {
char a;
cin >> a;
haha[i] = a-'0';
}
for(int i = 1; i <= n; i++) {
char a;
cin >> a;
bruh[i] = a-'0';
}
dp[0][0] = 1e9;
dp[0][1] = 1e9;
dp[0][2] = 0;
for(int i = 1; i <= n+1; i++) {
dp[i][0] = 1e9;
dp[i][1] = 1e9;
dp[i][2] = 1e9;
for(int j = 0; j < 3; j++) {
for(int k = 0; k < 3; k++) {
int a = haha[i-1],b = haha[i],br = dp[i-1][j];
if(j < 2) {
a = j;
}
if(k < 2) {
b = k;
}
if((a == bruh[i-1]) != (b == bruh[i])) {
br++;
}
if(j != k) {
if(j == 2 || k == 2) {
br++;
}
else {
br+=2;
}
}
dp[i][k] = min(dp[i][k],br);
}
}
}
cout << dp[n+1][2]/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... |