# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204071 | ics0503 | Lamps (JOI19_lamps) | C++17 | 68 ms | 16120 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<stdio.h>
int D[1212121][3];
char a[1212121], b[1212121];
int min(int a, int b) { if (a < b)return a; return b; }
int get(char a, int tp) {
if (tp == 0)return '0';
if (tp == 1)return '1';
return a;
}
int main() {
int n; scanf("%d%s%s", &n, a + 1, b + 1);
int i, j, k;
D[0][0] = D[0][1] = 1e9; D[0][2] = 0;
for (i = 1; i <= n; i++) {
for (j = 0; j < 3; j++) {
D[i][j] = 1e9;
for (k = 0; k < 3; k++) {
D[i][j] = min(D[i][j], D[i - 1][k]
+ (j != 2 && j != k)
+ ((i==1 || get(a[i - 1], k) == b[i - 1]) && get(a[i], j) != b[i]));
}
}
}
int ans = 1e9;
for (i = 0; i < 3; i++)ans = min(ans, D[n][i]);
printf("%d", ans);
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... |