이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* * In the name of GOD */
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define F first
#define S second
#define mk make_pair
const int N = 1012345;
int dp[N][3][2];
int32_t main() {
ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int n, ans = N;
string a, b;
cin >> n >> a >> b;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= 2; j++) {
for (int k = 0; k <= 1; k++) {
dp[i][j][k] = N;
if (i == 0) {
if (j == 2 && k == 0)
dp[i][j][k] = 0;
continue;
}
int x = (j == 2 ? a[i - 1] - '0' : j);
x ^= k;
if (x != b[i - 1] - '0') {
continue;
}
for (int j2 = 0; j2 <= 2; j2++) {
for (int k2 = 0; k2 <= 1; k2++) {
dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j2][k2] + ((j != 2) && (j2 != j)) + ((k != 0) && (k != k2)));
}
}
if (i == n)
ans = min(ans, dp[i][j][k]);
}
}
}
cout << ans << '\n';
}
# | 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... |