# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261533 | mjkocijan | Lamps (JOI19_lamps) | C++14 | 202 ms | 27772 KiB |
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;
#define X first
#define Y second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
#define MAXN 1001001
int n;
char a[MAXN], b[MAXN];
int dp[MAXN][3][2], reza = MAXN;
int main()
{
scanf("%d", &n);
scanf("%s", a);
scanf("%s", b);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 2; k++) {
dp[i][j][k] = MAXN;
for (int l = 0; l < 3; l++) {
for (int m = 0; m < 2; m++) {//cout << i <<' '<<j<<' '<<k<<'.'<<l<<' '<<m<<','<<dp[i][j][k]<<endl;
if (i == 0 && (l || m)) continue;//cout<<'.';
int bk;
if (j)
bk = (j - 1) ^ k;
else
bk = (a[i] - '0') ^ k;
if (bk != b[i] - '0') continue;//cout<<'/';
dp[i][j][k] = min(dp[i][j][k], (i ? dp[i - 1][l][m] : 0) + (j != l && j) * 2 + (k != m));
if (i == n - 1) reza = min(reza, dp[i][j][k]);
}
}
//cout << i << ' ' <<j <<' ' << k <<'.'<<dp[i][j][k]<<endl;
}
}
}
//cout << ceil(double(reza) / 2.0) << endl;
printf("%d\n", (int)ceil(double(reza) / 2.0));
return 0;
}
Compilation message (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... |